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()
|
||||
@disconnectClient()
|
||||
$('#app').hide().attr('style', 'display: none!important')
|
||||
App.Auth._logout()
|
||||
@delay(
|
||||
1200,
|
||||
window.location = App.Config.get('api_path') + '/sessions/switch/' + id
|
||||
->
|
||||
App.Auth._logout()
|
||||
window.location = App.Config.get('api_path') + '/sessions/switch/' + id
|
||||
1200
|
||||
)
|
||||
|
||||
edit = (id, e) =>
|
||||
|
|
|
@ -14,17 +14,22 @@
|
|||
###
|
||||
|
||||
class App.Ajax
|
||||
_instance = undefined # Must be declared here to force the closure on the class
|
||||
@request: (args) -> # Must be a static method
|
||||
_instance = undefined
|
||||
@request: (args) ->
|
||||
if _instance == undefined
|
||||
_instance ?= new _ajaxSingleton
|
||||
_instance.request(args)
|
||||
|
||||
@abort: (args) -> # Must be a static method
|
||||
@abort: (args) ->
|
||||
if _instance == undefined
|
||||
_instance ?= new _ajaxSingleton
|
||||
_instance.abort(args)
|
||||
|
||||
@abortAll: ->
|
||||
if _instance == undefined
|
||||
_instance ?= new _ajaxSingleton
|
||||
_instance.abortAll()
|
||||
|
||||
# The actual Singleton class
|
||||
class _ajaxSingleton
|
||||
defaults:
|
||||
|
@ -120,6 +125,14 @@ class _ajaxSingleton
|
|||
return
|
||||
)
|
||||
|
||||
abortAll: =>
|
||||
return if !@current_request
|
||||
abortedIds = []
|
||||
for id, ajax of @current_request
|
||||
@abort(id)
|
||||
abortedIds.push id
|
||||
abortedIds
|
||||
|
||||
_run: =>
|
||||
if @queue_list && @queue_list[0]
|
||||
@queue_running = true
|
||||
|
|
|
@ -135,6 +135,8 @@ class App.Auth
|
|||
@_logout: (data) ->
|
||||
App.Log.debug 'Auth', '_logout', data
|
||||
|
||||
App.Ajax.abortAll()
|
||||
|
||||
# empty session
|
||||
App.Session.init()
|
||||
|
||||
|
|
Loading…
Reference in a new issue