Improved logout session, abort all open ajax connections then.
This commit is contained in:
parent
eac4ccefde
commit
13d23f96cd
3 changed files with 22 additions and 6 deletions
|
@ -75,10 +75,11 @@ class Index extends App.Controller
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
@disconnectClient()
|
@disconnectClient()
|
||||||
$('#app').hide().attr('style', 'display: none!important')
|
$('#app').hide().attr('style', 'display: none!important')
|
||||||
App.Auth._logout()
|
|
||||||
@delay(
|
@delay(
|
||||||
1200,
|
->
|
||||||
|
App.Auth._logout()
|
||||||
window.location = App.Config.get('api_path') + '/sessions/switch/' + id
|
window.location = App.Config.get('api_path') + '/sessions/switch/' + id
|
||||||
|
1200
|
||||||
)
|
)
|
||||||
|
|
||||||
edit = (id, e) =>
|
edit = (id, e) =>
|
||||||
|
|
|
@ -14,17 +14,22 @@
|
||||||
###
|
###
|
||||||
|
|
||||||
class App.Ajax
|
class App.Ajax
|
||||||
_instance = undefined # Must be declared here to force the closure on the class
|
_instance = undefined
|
||||||
@request: (args) -> # Must be a static method
|
@request: (args) ->
|
||||||
if _instance == undefined
|
if _instance == undefined
|
||||||
_instance ?= new _ajaxSingleton
|
_instance ?= new _ajaxSingleton
|
||||||
_instance.request(args)
|
_instance.request(args)
|
||||||
|
|
||||||
@abort: (args) -> # Must be a static method
|
@abort: (args) ->
|
||||||
if _instance == undefined
|
if _instance == undefined
|
||||||
_instance ?= new _ajaxSingleton
|
_instance ?= new _ajaxSingleton
|
||||||
_instance.abort(args)
|
_instance.abort(args)
|
||||||
|
|
||||||
|
@abortAll: ->
|
||||||
|
if _instance == undefined
|
||||||
|
_instance ?= new _ajaxSingleton
|
||||||
|
_instance.abortAll()
|
||||||
|
|
||||||
# The actual Singleton class
|
# The actual Singleton class
|
||||||
class _ajaxSingleton
|
class _ajaxSingleton
|
||||||
defaults:
|
defaults:
|
||||||
|
@ -120,6 +125,14 @@ class _ajaxSingleton
|
||||||
return
|
return
|
||||||
)
|
)
|
||||||
|
|
||||||
|
abortAll: =>
|
||||||
|
return if !@current_request
|
||||||
|
abortedIds = []
|
||||||
|
for id, ajax of @current_request
|
||||||
|
@abort(id)
|
||||||
|
abortedIds.push id
|
||||||
|
abortedIds
|
||||||
|
|
||||||
_run: =>
|
_run: =>
|
||||||
if @queue_list && @queue_list[0]
|
if @queue_list && @queue_list[0]
|
||||||
@queue_running = true
|
@queue_running = true
|
||||||
|
|
|
@ -135,6 +135,8 @@ class App.Auth
|
||||||
@_logout: (data) ->
|
@_logout: (data) ->
|
||||||
App.Log.debug 'Auth', '_logout', data
|
App.Log.debug 'Auth', '_logout', data
|
||||||
|
|
||||||
|
App.Ajax.abortAll()
|
||||||
|
|
||||||
# empty session
|
# empty session
|
||||||
App.Session.init()
|
App.Session.init()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue