Get user name from vk if logins for the first time
This commit is contained in:
parent
6be5868588
commit
a74376009a
|
@ -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
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue