diff --git a/app/assets/javascripts/app/lib/app_post/auth.js.coffee b/app/assets/javascripts/app/lib/app_post/auth.js.coffee index cd59209a6..1ea34cd59 100644 --- a/app/assets/javascripts/app/lib/app_post/auth.js.coffee +++ b/app/assets/javascripts/app/lib/app_post/auth.js.coffee @@ -30,7 +30,7 @@ class App.Auth success: (data, status, xhr) => # set login (config, session, ...) - @_login(data) + @_login(data, 'check') error: (xhr, statusText, error) => @_loginError() @@ -51,7 +51,7 @@ class App.Auth @_loginError() ) - @_login: (data) -> + @_login: (data, type) -> App.Log.notice 'Auth', '_login:success', data # if session is not valid @@ -71,6 +71,10 @@ class App.Auth return false; + # clear local store + if type isnt 'check' + App.Event.trigger( 'clearStore' ) + # set avatar data.session.image = App.Config.get('api_path') + '/users/image/' + data.session.image @@ -110,6 +114,7 @@ class App.Auth App.Event.trigger( 'auth' ) App.Event.trigger( 'auth:logout' ) App.Event.trigger( 'ui:rerender' ) + App.Event.trigger( 'clearStore' ) @_loginError: (xhr, statusText, error) -> App.Log.notice 'Auth', '_loginError:error' @@ -121,3 +126,5 @@ class App.Auth App.Event.trigger( 'auth' ) App.Event.trigger( 'auth:logout' ) App.Event.trigger( 'ui:rerender' ) + App.Event.trigger( 'clearStore' ) + diff --git a/app/assets/javascripts/app/lib/app_post/store.js.coffee b/app/assets/javascripts/app/lib/app_post/store.js.coffee index dad2ccd68..a45d02fe6 100644 --- a/app/assets/javascripts/app/lib/app_post/store.js.coffee +++ b/app/assets/javascripts/app/lib/app_post/store.js.coffee @@ -39,7 +39,7 @@ class _storeSingleton # clear store on every login/logout if @support - App.Event.bind 'auth', => + App.Event.bind 'clearStore', => @clear('all') # write to local storage