|
@@ -14,10 +14,13 @@ class App.Auth
|
|
|
# clear store
|
|
|
App.Store.clear('all')
|
|
|
|
|
|
+ @_login(data)
|
|
|
+
|
|
|
# execute callback
|
|
|
params.success(data, status, xhr)
|
|
|
|
|
|
error: (xhr, statusText, error) =>
|
|
|
+ @_loginError()
|
|
|
params.error(xhr, statusText, error)
|
|
|
)
|
|
|
|
|
@@ -29,77 +32,86 @@ class App.Auth
|
|
|
type: 'GET'
|
|
|
url: '/signshow'
|
|
|
success: (data, status, xhr) =>
|
|
|
- App.Log.log 'Auth', 'notice', 'logincheck:success', data
|
|
|
+ @_login(data)
|
|
|
|
|
|
- # if session is not valid
|
|
|
- if data.error
|
|
|
-
|
|
|
- # update config
|
|
|
- for key, value of data.config
|
|
|
- App.Config.set( key, value )
|
|
|
+ error: (xhr, statusText, error) =>
|
|
|
+ @_loginError()
|
|
|
+ )
|
|
|
|
|
|
- # empty session
|
|
|
- App.Session.init()
|
|
|
+ @logout: ->
|
|
|
+ App.Log.log 'Auth', 'notice', 'logout'
|
|
|
+ App.Com.ajax(
|
|
|
+ id: 'logout'
|
|
|
+ type: 'DELETE'
|
|
|
+ url: '/signout'
|
|
|
+ success: =>
|
|
|
+ @_logout()
|
|
|
|
|
|
- # update websocked auth info
|
|
|
- App.WebSocket.auth()
|
|
|
+ error: (xhr, statusText, error) =>
|
|
|
+ @_loginError()
|
|
|
+ )
|
|
|
|
|
|
- # rebuild navbar with new navbar items
|
|
|
- App.Event.trigger 'ajax:auth'
|
|
|
+ @_login: (data) ->
|
|
|
+ App.Log.log 'Auth', 'notice', '_login:success', data
|
|
|
|
|
|
- return false;
|
|
|
+ # if session is not valid
|
|
|
+ if data.error
|
|
|
|
|
|
- # set avatar
|
|
|
- if !data.session.image
|
|
|
- data.session.image = 'http://placehold.it/48x48'
|
|
|
+ # update config
|
|
|
+ for key, value of data.config
|
|
|
+ App.Config.set( key, value )
|
|
|
|
|
|
- # update config
|
|
|
- for key, value of data.config
|
|
|
- App.Config.set( key, value )
|
|
|
+ # empty session
|
|
|
+ App.Session.init()
|
|
|
|
|
|
- # store user data
|
|
|
- for key, value of data.session
|
|
|
- App.Session.set( key, value )
|
|
|
+ # update websocked auth info
|
|
|
+ App.WebSocket.auth()
|
|
|
|
|
|
- # update websocked auth info
|
|
|
- App.WebSocket.auth()
|
|
|
+ # rebuild navbar with new navbar items
|
|
|
+ App.Event.trigger 'ajax:auth'
|
|
|
|
|
|
- # refresh/load default collections
|
|
|
- for key, value of data.default_collections
|
|
|
- App.Collection.reset( type: key, data: value )
|
|
|
+ return false;
|
|
|
|
|
|
- # rebuild navbar with new navbar items
|
|
|
- App.Event.trigger 'ajax:auth', data.session
|
|
|
+ # set avatar
|
|
|
+ if !data.session.image
|
|
|
+ data.session.image = 'http://placehold.it/48x48'
|
|
|
|
|
|
- error: (xhr, statusText, error) =>
|
|
|
- App.Log.log 'Auth', 'notice', 'logincheck:error'
|
|
|
+ # update config
|
|
|
+ for key, value of data.config
|
|
|
+ App.Config.set( key, value )
|
|
|
|
|
|
- # empty session
|
|
|
- App.Session.init()
|
|
|
+ # store user data
|
|
|
+ for key, value of data.session
|
|
|
+ App.Session.set( key, value )
|
|
|
|
|
|
- # clear store
|
|
|
- App.Store.clear('all')
|
|
|
+ # refresh default collections
|
|
|
+ for key, value of data.default_collections
|
|
|
+ App[key].refresh( value, options: { clear: true } )
|
|
|
|
|
|
- # update websocked auth info
|
|
|
- App.WebSocket.auth()
|
|
|
- )
|
|
|
+ # update websocked auth info
|
|
|
+ App.WebSocket.auth()
|
|
|
|
|
|
- @logout: ->
|
|
|
- App.Log.log 'Auth', 'notice', 'logout'
|
|
|
- App.Com.ajax(
|
|
|
- id: 'logout'
|
|
|
- type: 'DELETE'
|
|
|
- url: '/signout'
|
|
|
- success: =>
|
|
|
+ # rebuild navbar with user data
|
|
|
+ App.Event.trigger 'ajax:auth', data.session
|
|
|
|
|
|
- # update websocked auth info
|
|
|
- App.WebSocket.auth()
|
|
|
|
|
|
- # clear store
|
|
|
- App.Store.clear('all')
|
|
|
+ @_logout: (data) ->
|
|
|
+ App.Log.log 'Auth', 'notice', '_logout'
|
|
|
|
|
|
- error: (xhr, statusText, error) =>
|
|
|
+ # update websocked auth info
|
|
|
+ App.WebSocket.auth()
|
|
|
+
|
|
|
+ # clear store
|
|
|
+ App.Store.clear('all')
|
|
|
+
|
|
|
+ @_loginError: (xhr, statusText, error) ->
|
|
|
+ App.Log.log 'Auth', 'notice', '_loginError:error'
|
|
|
+
|
|
|
+ # empty session
|
|
|
+ App.Session.init()
|
|
|
+
|
|
|
+ # clear store
|
|
|
+ App.Store.clear('all')
|
|
|
|
|
|
- # update websocked auth info
|
|
|
- App.WebSocket.auth()
|
|
|
- )
|
|
|
+ # update websocked auth info
|
|
|
+ App.WebSocket.auth()
|