couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject [23/50] [abbrv] couchdb commit: updated refs/heads/1.6.x to d2ac597
Date Tue, 01 Apr 2014 17:42:05 GMT
Fauxton: Redirected to correct page after login

Fixes COUCHDB-2209


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/198bea34
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/198bea34
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/198bea34

Branch: refs/heads/1.6.x
Commit: 198bea3479dfecac13ab1a3e95f902b8eba02f7d
Parents: 0f7be28
Author: Garren Smith <garren.smith@gmail.com>
Authored: Tue Mar 25 17:54:33 2014 +0200
Committer: Garren Smith <garren.smith@gmail.com>
Committed: Tue Mar 25 17:54:33 2014 +0200

----------------------------------------------------------------------
 src/fauxton/app/addons/auth/base.js             |  3 ++-
 src/fauxton/app/addons/auth/resources.js        | 21 +++++++++++++++++++-
 src/fauxton/app/addons/auth/routes.js           | 13 ++++++++++--
 .../app/addons/auth/templates/noAccess.html     |  4 +++-
 src/fauxton/app/core/auth.js                    |  2 --
 5 files changed, 36 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/198bea34/src/fauxton/app/addons/auth/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/auth/base.js b/src/fauxton/app/addons/auth/base.js
index c7bbb04..b8545fc 100644
--- a/src/fauxton/app/addons/auth/base.js
+++ b/src/fauxton/app/addons/auth/base.js
@@ -52,7 +52,8 @@ function(app, FauxtonAPI, Auth) {
     };
 
     var authDenied = function () {
-      FauxtonAPI.navigate('/noAccess', {replace: true});
+      var url = window.location.hash.replace('#','');
+      FauxtonAPI.navigate('/noAccess?urlback=' + url, {replace: true});
     };
 
     FauxtonAPI.auth.registerAuth(auth);

http://git-wip-us.apache.org/repos/asf/couchdb/blob/198bea34/src/fauxton/app/addons/auth/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/auth/resources.js b/src/fauxton/app/addons/auth/resources.js
index 71744e3..edfd708 100644
--- a/src/fauxton/app/addons/auth/resources.js
+++ b/src/fauxton/app/addons/auth/resources.js
@@ -252,6 +252,9 @@ function (app, FauxtonAPI, CouchdbSession) {
 
   Auth.LoginView = FauxtonAPI.View.extend({
     template: 'addons/auth/templates/login',
+    initialize: function (options) {
+      this.urlBack = options.urlBack || "";
+    },
 
     events: {
       "submit #login": "login"
@@ -263,10 +266,16 @@ function (app, FauxtonAPI, CouchdbSession) {
       var that = this,
           username = this.$('#username').val(),
           password = this.$('#password').val(),
+          urlBack = this.urlBack,
           promise = this.model.login(username, password);
 
       promise.then(function () {
         FauxtonAPI.addNotification({msg:  FauxtonAPI.session.messages.loggedIn });
+
+        if (urlBack) {
+          return FauxtonAPI.navigate(urlBack);
+        }
+
         FauxtonAPI.navigate('/');
       });
 
@@ -346,7 +355,17 @@ function (app, FauxtonAPI, CouchdbSession) {
   });
 
   Auth.NoAccessView = FauxtonAPI.View.extend({
-    template: "addons/auth/templates/noAccess"
+    template: "addons/auth/templates/noAccess",
+
+    initialize: function (options) {
+      this.urlBack = options.urlBack || "";
+    },
+
+    serialize: function () {
+      return {
+        urlBack: this.urlBack
+      };
+    }
   });
 
   return Auth;

http://git-wip-us.apache.org/repos/asf/couchdb/blob/198bea34/src/fauxton/app/addons/auth/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/auth/routes.js b/src/fauxton/app/addons/auth/routes.js
index fe40a77..74395e8 100644
--- a/src/fauxton/app/addons/auth/routes.js
+++ b/src/fauxton/app/addons/auth/routes.js
@@ -21,15 +21,21 @@ function(app, FauxtonAPI, Auth) {
     layout: 'one_pane',
 
     routes: {
+      'login?*extra': 'login',
       'login': 'login',
       'logout': 'logout',
       'createAdmin': 'createAdmin',
+      'noAccess?*extra': 'noAccess',
       'noAccess': 'noAccess'
     },
 
     login: function () {
+      var urlBack = app.getParams().urlback;
       this.crumbs = [{name: 'Login', link:"#"}];
-      this.setView('#dashboard-content', new Auth.LoginView({model: FauxtonAPI.session}));
+      this.setView('#dashboard-content', new Auth.LoginView({
+        model: FauxtonAPI.session,
+        urlBack: urlBack
+      }));
     },
 
     logout: function () {
@@ -50,8 +56,11 @@ function(app, FauxtonAPI, Auth) {
     },
 
     noAccess: function () {
+      var urlBack = app.getParams().urlback;
       this.crumbs = [{name: 'Access Denied', link:"#"}];
-      this.setView('#dashboard-content', new Auth.NoAccessView());
+      this.setView('#dashboard-content', new Auth.NoAccessView({
+        urlBack: urlBack
+      }));
       this.apiUrl = 'noAccess';
     },
   });

http://git-wip-us.apache.org/repos/asf/couchdb/blob/198bea34/src/fauxton/app/addons/auth/templates/noAccess.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/auth/templates/noAccess.html b/src/fauxton/app/addons/auth/templates/noAccess.html
index ceff992..ffa736e 100644
--- a/src/fauxton/app/addons/auth/templates/noAccess.html
+++ b/src/fauxton/app/addons/auth/templates/noAccess.html
@@ -15,6 +15,8 @@ the License.
 
 <div class="span12">
   <h2> Access Denied </h2>
-  <p> You do not have permission to view this page. <br/> You might need to <a
href="#login"> login </a> to view this page/ </p>
+  <p> You do not have permission to view this page. <br/> 
+  You might need to <a href="#login<% if (urlBack){ %>?urlback=<%=urlBack%>
 <% } %> "> login </a> to view this page/ 
+ </p>
   
 </div>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/198bea34/src/fauxton/app/core/auth.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/auth.js b/src/fauxton/app/core/auth.js
index 15cf566..19e4a8c 100644
--- a/src/fauxton/app/core/auth.js
+++ b/src/fauxton/app/core/auth.js
@@ -60,8 +60,6 @@ function(FauxtonAPI, Backbone) {
     }
   });
 
-//  FauxtonAPI.auth = new Auth();
-
   return Auth;
 });
 


Mime
View raw message