1
0
Fork 0
oldhaven/app/assets/javascripts/session.coffee

33 lines
607 B
CoffeeScript

class window.Session
vk_params: null
user: null
constructor: (params) ->
attrs = ['expire', 'mid', 'secret', 'sid', 'sig']
_params = {}
for key in attrs
if params[key]?
_params[key] = params[key]
@vk_params = _params
setUser: (user) ->
@user = user
_beathaven.lang = @user.lang || 'ru'
_beathaven.localizeHTML()
false
getUser: ->
@user
query: (url, params, callback) ->
q_params = $.extend {}, @vk_params, params
$.post url, q_params, callback
false
reloadSession: ->
_session.query '/user/auth', {}, (ar) ->
_session.setUser ar.user
false
false