couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robertkowal...@apache.org
Subject fauxton commit: updated refs/heads/master to a02cc7f
Date Thu, 23 Oct 2014 13:48:55 GMT
Repository: couchdb-fauxton
Updated Branches:
  refs/heads/master 1dadfc1ec -> a02cc7fe0


Fix disappearing logout link

Also add header link when user is already logged in and is reloading
the browser which does not change the session

Closes COUCHDB-2357


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

Branch: refs/heads/master
Commit: a02cc7fe0bb1598a5b56d811e79c9181bd3b5c25
Parents: 1dadfc1
Author: Luis Gerhorst <luis@luisgerhorst.de>
Authored: Wed Oct 8 19:05:47 2014 +0200
Committer: Robert Kowalski <robertkowalski@apache.org>
Committed: Thu Oct 23 15:48:10 2014 +0200

----------------------------------------------------------------------
 app/addons/auth/base.js          | 24 +++++++++++++++++++-----
 app/addons/auth/test/baseSpec.js |  1 +
 2 files changed, 20 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/a02cc7fe/app/addons/auth/base.js
----------------------------------------------------------------------
diff --git a/app/addons/auth/base.js b/app/addons/auth/base.js
index b8545fc..966e3af 100644
--- a/app/addons/auth/base.js
+++ b/app/addons/auth/base.js
@@ -23,17 +23,18 @@ function(app, FauxtonAPI, Auth) {
   app.session = Auth.session;
 
   Auth.initialize = function() {
+
     Auth.navLink = new Auth.NavLink({model: Auth.session});
 
     FauxtonAPI.addHeaderLink({
-      title: "Auth", 
+      title: "Auth",
       href: "#_auth",
       view: Auth.navLink,
       icon: "fonticon-user",
       bottomNav: true,
       establish: [FauxtonAPI.session.fetchUser()]
     });
-      
+
 
     var auth = function (session, roles) {
       var deferred = $.Deferred();
@@ -59,15 +60,28 @@ function(app, FauxtonAPI, Auth) {
     FauxtonAPI.auth.registerAuth(auth);
     FauxtonAPI.auth.registerAuthDenied(authDenied);
 
+
+    var addLogoutLink = function () {
+      FauxtonAPI.addHeaderLink({footerNav: true, href: "#logout", title: "Logout", icon:
"", className: 'logout'});
+    };
+
+    var removeLogoutLink = function () {
+      FauxtonAPI.removeHeaderLink({title: "Logout", footerNav: true});
+    };
+
+    if (FauxtonAPI.session.isLoggedIn()) {
+      addLogoutLink();
+    }
+
     FauxtonAPI.session.on('change', function () {
       if (FauxtonAPI.session.isLoggedIn()) {
-        FauxtonAPI.addHeaderLink({footerNav: true, href:"#logout", title:"Logout", icon:
"", className: 'logout'});
+        addLogoutLink();
       } else {
-        FauxtonAPI.removeHeaderLink({title: "Logout", footerNav: true});
+        removeLogoutLink();
       }
     });
-  };
 
+  };
 
   return Auth;
 });

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/a02cc7fe/app/addons/auth/test/baseSpec.js
----------------------------------------------------------------------
diff --git a/app/addons/auth/test/baseSpec.js b/app/addons/auth/test/baseSpec.js
index ad92ec8..009aff5 100644
--- a/app/addons/auth/test/baseSpec.js
+++ b/app/addons/auth/test/baseSpec.js
@@ -25,6 +25,7 @@ define([
       it("redirects with replace: true set", function () {
         var navigateSpy = sinon.spy(FauxtonAPI, 'navigate');
         FauxtonAPI.auth = new Auth();
+        FauxtonAPI.session.isLoggedIn = function () { return false; };
         Base.initialize();
         FauxtonAPI.auth.authDeniedCb();
         assert.ok(navigateSpy.withArgs('/noAccess?urlback=', {replace: true}).calledOnce);


Mime
View raw message