From ecea57babaa98c49125e861a0f29e807d304aa9f Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 11 Apr 2012 08:34:11 +0200 Subject: [PATCH] Added remember to url feature. --- .../app/controllers/_application_controller.js.coffee | 5 +++++ app/assets/javascripts/app/controllers/login.js.coffee | 8 +++++++- app/assets/javascripts/init.js | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) 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 = {};