diff --git a/app/assets/javascripts/app/controllers/_application_controller.js.coffee b/app/assets/javascripts/app/controllers/_application_controller.js.coffee index b93a692b9..86c16880d 100644 --- a/app/assets/javascripts/app/controllers/_application_controller.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller.js.coffee @@ -484,8 +484,13 @@ class App.Controller extends Spine.Controller authenticate: -> console.log 'authenticate', window.Session + + # return rtue if session exists return true if window.Session['id'] + # remember requested url + window.Config['requested_url'] = window.location.hash + # redirect to login @navigate '#login' return false diff --git a/app/assets/javascripts/app/controllers/login.js.coffee b/app/assets/javascripts/app/controllers/login.js.coffee index 62613a4dc..328cae302 100644 --- a/app/assets/javascripts/app/controllers/login.js.coffee +++ b/app/assets/javascripts/app/controllers/login.js.coffee @@ -71,7 +71,13 @@ class Index extends App.Controller } # redirect to # - @navigate '#/' + if window.Config['requested_url'] isnt '' + @navigate window.Config['requested_url'] + + # reset + window.Config['requested_url'] = '' + else + @navigate '#/' error: (xhr, statusText, error) => console.log 'login:error' diff --git a/app/assets/javascripts/init.js b/app/assets/javascripts/init.js index 9e66472fd..81f141b05 100644 --- a/app/assets/javascripts/init.js +++ b/app/assets/javascripts/init.js @@ -2,4 +2,5 @@ var Config = {}; Config.Routes = {}; Config.NavBar = {}; Config.product_name = 'Zammad' +Config.requested_url = '' var Session = {};