You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by de...@apache.org on 2014/03/25 17:13:38 UTC
couchdb commit: updated refs/heads/master to 198bea3
Repository: couchdb
Updated Branches:
refs/heads/master 0f7be287d -> 198bea347
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/master
Commit: 198bea3479dfecac13ab1a3e95f902b8eba02f7d
Parents: 0f7be28
Author: Garren Smith <ga...@gmail.com>
Authored: Tue Mar 25 17:54:33 2014 +0200
Committer: Garren Smith <ga...@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;
});