Avoid http redirects, they will be cached on some browsers.

This commit is contained in:
Martin Edenhofer 2016-01-26 00:52:29 +01:00
parent 13d23f96cd
commit 7d6ab22cae
3 changed files with 43 additions and 22 deletions

View file

@ -574,6 +574,22 @@ class App.Controller extends Spine.Controller
e.currentTarget.focus() e.currentTarget.focus()
e.currentTarget.select() e.currentTarget.select()
windowReload: (e,url) ->
if e
e.preventDefault()
$('#app').hide().attr('style', 'display: none!important')
if url
window.location = url
return true
if window.location.reload
window.location.reload()
return true
if window.location.href
window.location.href = window.location.href
return true
throw 'Cant reload page!'
class App.ControllerPermanent extends App.Controller class App.ControllerPermanent extends App.Controller
constructor: -> constructor: ->
super super
@ -726,31 +742,18 @@ class App.ControllerModal extends App.Controller
class App.SessionMessage extends App.ControllerModal class App.SessionMessage extends App.ControllerModal
onCancel: (e) => onCancel: (e) =>
if @forceReload if @forceReload
@reload(e) @windowReload(e)
onClose: (e) => onClose: (e) =>
if @forceReload if @forceReload
@reload(e) @windowReload(e)
onSubmit: (e) => onSubmit: (e) =>
if @forceReload if @forceReload
@reload(e) @windowReload(e)
else else
@close() @close()
reload: (e) ->
if e
e.preventDefault()
$('#app').hide().attr('style', 'display: none!important')
if window.location.reload
window.location.reload()
return true
if window.location.href
window.location.href = window.location.href
return true
throw 'Cant reload page!'
class App.UpdateHeader extends App.Controller class App.UpdateHeader extends App.Controller
constructor: -> constructor: ->
super super

View file

@ -76,10 +76,17 @@ class Index extends App.Controller
@disconnectClient() @disconnectClient()
$('#app').hide().attr('style', 'display: none!important') $('#app').hide().attr('style', 'display: none!important')
@delay( @delay(
-> =>
App.Auth._logout() App.Auth._logout()
window.location = App.Config.get('api_path') + '/sessions/switch/' + id @ajax(
1200 id: 'user_switch'
type: 'GET'
url: "#{@apiPath}/sessions/switch/#{id}"
success: (data, status, xhr) =>
location = "#{window.location.protocol}//#{window.location.host}#{data.location}"
@windowReload(undefined, location)
)
800
) )
edit = (id, e) => edit = (id, e) =>

View file

@ -34,7 +34,18 @@ class Widget extends App.ControllerWidgetOnDemand
e.preventDefault() e.preventDefault()
@disconnectClient() @disconnectClient()
$('#app').hide().attr('style', 'display: none!important') $('#app').hide().attr('style', 'display: none!important')
@delay(
=>
App.Auth._logout() App.Auth._logout()
window.location = App.Config.get('api_path') + '/sessions/switch_back' @ajax(
id: 'user_switch_back'
type: 'GET'
url: "#{@apiPath}/sessions/switch_back"
success: (data, status, xhr) =>
location = "#{window.location.protocol}//#{window.location.host}#{data.location}"
@windowReload(undefined, location)
)
800
)
App.Config.set( 'switch_back_to_user', Widget, 'Widgets' ) App.Config.set( 'switch_back_to_user', Widget, 'Widgets' )