1
0
Fork 0

Get user name from vk if logins for the first time

This commit is contained in:
Gregory Eremin 2011-09-26 15:03:52 +04:00
parent 6be5868588
commit a74376009a
3 changed files with 10 additions and 6 deletions

View File

@ -44,7 +44,7 @@ $ ->
$('.dropdown-menu li a').live 'click', ->
$(this).parent().parent().parent().toggleClass('open')
false
$('.foreign-link').live 'click', ->
$('.foreign-link').live 'click', (e) ->
# window.open($(this).attr('href'))
e.preventDefault();
false

View File

@ -22,12 +22,9 @@ class window.Vkontakte
if typeof response isnt 'undefined' and response.session
_session = new Session(response.session)
_session.query '/user/auth', {}, (ar) ->
if ar.ok_reload
window.location.reload()
false
if ar.newbie
VK.Api.call 'getVariable', key: 1281, (r) ->
_session.query '/user/update', name: r.response, (ar2) ->
_session.query '/user/update', params: { name: r.response }, (ar2) ->
_session.setUser ar2.user
$('#username')
.html (if _session.getUser().name then _session.getUser().name else '%username%')
@ -35,6 +32,12 @@ class window.Vkontakte
_ajax.detectPage()
_session.displayAuthorizedContent()
$('#authorized').css display: 'block'
if ar.ok_reload
window.location.reload()
false
else if ar.ok_reload
window.location.reload()
false
else
_session.setUser ar.user

View File

@ -16,7 +16,8 @@ class UserController < ApplicationController
if session.key != session_key
session.key = session_key
session.save
render :json => { 'ok_reload' => true }
@res[:ok_reload] = true
render :json => @res
return
end