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 cb965178d..653cb6590 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,34 +28,56 @@ function(jquery,ui,sammy,tmpl,i18n,jqueryCookie,bootstrap,archivaSearch,jqueryVa * @param user see user.js */ reccordLoginCookie=function(user) { - var path = window.redbackRuntimeConfiguration.findPropertyValue("security.rememberme.timeout"); + + var path = window.redbackRuntimeConfiguration.findPropertyValue("security.rememberme.path"); 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 - } - ); + var expires= Number(window.redbackRuntimeConfiguration.findPropertyValue("security.rememberme.timeout")); + + var userJson=ko.toJSON(user); + + $.log("reccordLoginCookie:expires:"+expires+",path:"+path+",domain:"+domain+",secure:"+secure+",user:"+userJson); + + var options = null; + if (secure == 'true'){ + options = { + expires: expires, + path: path, + domain: domain, + secure: secure + } + }else { + options = { + expires: expires, + path: path, + domain: domain + } + } + + $.cookie('archiva_login', userJson,options); }; getUserFromLoginCookie=function(){ var cookieContent=$.cookie('archiva_login'); $.log("archiva_login cookie content:"+cookieContent); - return $.parseJSON(cookieContent); + var user = $.parseJSON(cookieContent); + if(!user){ + return null; + } + var kUser = new User(user.username, user.password, user.confirmPassword,user.fullName,user.email,user.permanent,user.validated, + user.timestampAccountCreation,user.timestampLastLogin,user.timestampLastPasswordChange,user.locked, + user.passwordChangeRequired,null,user.readOnly,user.userManagerId) + + kUser.rememberme(user.rememberme); + return kUser; }; - deleteLoginCookie=function(){ - $.cookie('archiva_login', null,{ expires: 7, path: '/' }); - }; + logout=function(doScreenChange){ - //deleteLoginCookie(); var user = getUserFromLoginCookie(); if(user){ user.logged=false; @@ -719,7 +741,7 @@ function(jquery,ui,sammy,tmpl,i18n,jqueryCookie,bootstrap,archivaSearch,jqueryVa }; userLoggedCallbackFn=function(user){ - $.log("userLoggedCallbackFn:"+ (user?user.username:null)); + $.log("userLoggedCallbackFn:"+ (user?user.username():null)); var loginLink=$("#login-link"); var registerLink=$("#register-link"); var changePasswordLink=$("#change-password-link"); 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 b8469ddff..f7d4bf2ee 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 @@ -82,7 +82,7 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,purl) { this.userManagerId=userManagerId; - this.rememberme=false; + this.rememberme=ko.observable(false); this.logged=false; @@ -356,10 +356,10 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,purl) { var user=getUserFromLoginCookie(); if(user){ - $.log("found user in cookie rememberme:"+(user.rememberme)); - if(user.rememberme){ - $("#user-login-form-username" ).val(user.username); - $("#user-login-form-password" ).val(user.password); + $.log("found user in cookie rememberme:"+(user.rememberme())); + if(user.rememberme()){ + $("#user-login-form-username" ).val(user.username()); + $("#user-login-form-password" ).val(user.password()); $("#user-login-form-rememberme" ).attr("checked","true"); } } else { @@ -429,11 +429,11 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,purl) { } // FIXME check validated - user.rememberme=window.redbackModel.rememberme; - if(user.rememberme){ + user.rememberme(window.redbackModel.rememberme); + if(user.rememberme()){ user.password(window.redbackModel.password); } - $.log("user.rememberme:"+(user.rememberme)); + $.log("user.rememberme:"+(user.rememberme())); reccordLoginCookie(user); window.user=user; $("#login-link").hide();