From 95fd5712edea91d3f1096f90c71fab970017320c Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 19 Dec 2012 23:47:13 +0000 Subject: [PATCH] more options for rememberme cookie settings git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1424231 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/archiva/i18n/default.properties | 5 ++++- .../src/main/webapp/js/archiva/main.js | 15 ++++++++++++++- .../src/main/webapp/js/redback/user.js | 7 +++---- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties index a71b44660..ea1b7949d 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties @@ -566,7 +566,10 @@ ldap.config.max.result.count.help.content=Maximum of result when searching users security.policy.password.rule.numericalcount.enabled.help.content=Minimum of number characters in the password. security.policy.allowed.login.attempt.help.content=Maximum number of login attempt before loking account. security.rememberme.enabled.help.content=Enable rememberme on login. -security.rememberme.timeout.help.content=Timeout in minutes for rememberme cookie. +security.rememberme.timeout.help.content=Timeout in days for rememberme cookie. +security.rememberme.path.help.content=Path for rememberme cookie. +security.rememberme.secure.help.content=rememberme cookie secured. +security.rememberme.domain.help.content=rememberme cookie domain. security.policy.unlockable.accounts.help.content=Non lockable accounts. ldap.config.mapper.attribute.fullname.help.content=The name of the attribute on a user that contains the users fullName. security.policy.password.rule.characterlength.enabled.help.content=Character length password rule enabled. diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js index 70caaee49..cb965178d 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js @@ -28,7 +28,20 @@ function(jquery,ui,sammy,tmpl,i18n,jqueryCookie,bootstrap,archivaSearch,jqueryVa * @param user see user.js */ reccordLoginCookie=function(user) { - $.cookie('archiva_login', ko.toJSON(user),{ expires: 7, path: '/' }); + var path = window.redbackRuntimeConfiguration.findPropertyValue("security.rememberme.timeout"); + path = path ? path : "/"; + + var domain = window.redbackRuntimeConfiguration.findPropertyValue("security.rememberme.domain"); + var secure = window.redbackRuntimeConfiguration.findPropertyValue("security.rememberme.secure"); + + $.cookie('archiva_login', ko.toJSON(user), + { + expires: Number(window.redbackRuntimeConfiguration.findPropertyValue("security.rememberme.timeout")), + path: path, + domain: domain, + secure: secure + } + ); }; getUserFromLoginCookie=function(){ diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js index 314a1103b..b8469ddff 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js @@ -421,11 +421,11 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,purl) { changePasswordBox(true,false,user); return; } - // not really needed as an exception is returned but "ceintures et bretelles" as we said in French :-) + // not really needed as an exception is returned but "ceintures et bretelles" as we say in French :-) if (user.locked()==true){ $.log("user locked"); displayErrorMessage($.i18n.prop("account.locked")); - return + return; } // FIXME check validated @@ -435,6 +435,7 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,purl) { } $.log("user.rememberme:"+(user.rememberme)); reccordLoginCookie(user); + window.user=user; $("#login-link").hide(); $("#logout-link").show(); $("#register-link").hide(); @@ -582,11 +583,9 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,purl) { } $("#modal-login-ok").button("loading"); - //#modal-login-footer $('#modal-login-footer').append(smallSpinnerImg()); var rememberme=($("#user-login-form-rememberme" ).attr('checked')=='checked'); - $.log("rememberme:"+rememberme); window.redbackModel.rememberme=rememberme; window.redbackModel.password=$("#user-login-form-password").val();