mirror of https://github.com/apache/archiva.git
[MRM-1699] Re implement remember me in new UI.
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1400163 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f34d32f93c
commit
70b46f383c
|
@ -28,19 +28,26 @@ function(jquery,ui,sammy,tmpl,i18n,jqueryCookie,bootstrap,archivaSearch,jqueryVa
|
|||
* @param user see user.js
|
||||
*/
|
||||
reccordLoginCookie=function(user) {
|
||||
$.cookie('redback_login', ko.toJSON(user));
|
||||
$.cookie('archiva_login', ko.toJSON(user));
|
||||
};
|
||||
|
||||
getUserFromLoginCookie=function(){
|
||||
return $.parseJSON($.cookie('redback_login'));
|
||||
var cookieContent=$.cookie('archiva_login');
|
||||
$.log("archiva_login cookie content:"+cookieContent);
|
||||
return $.parseJSON(cookieContent);
|
||||
};
|
||||
|
||||
deleteLoginCookie=function(){
|
||||
$.cookie('redback_login', null);
|
||||
$.cookie('archiva_login', null);
|
||||
};
|
||||
|
||||
logout=function(doScreenChange){
|
||||
deleteLoginCookie();
|
||||
//deleteLoginCookie();
|
||||
var user = getUserFromLoginCookie();
|
||||
if(user){
|
||||
user.logged=false;
|
||||
reccordLoginCookie(user);
|
||||
}
|
||||
$("#login-link").show();
|
||||
$("#register-link").show();
|
||||
$("#logout-link").hide();
|
||||
|
|
|
@ -76,6 +76,10 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) {
|
|||
|
||||
this.modified=ko.observable(false);
|
||||
|
||||
this.rememberme=false;
|
||||
this.password=null;
|
||||
this.logged=false;
|
||||
|
||||
this.remove = function() {
|
||||
if (ownerViewModel) {
|
||||
ownerViewModel.users.destroy(this);
|
||||
|
@ -142,7 +146,7 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) {
|
|||
checkCreateAdminLink();
|
||||
checkSecurityLinks();
|
||||
}
|
||||
loginCall(currentAdminUser.username(), currentAdminUser.password(),onSuccessCall);
|
||||
loginCall(currentAdminUser.username(), currentAdminUser.password(),false,onSuccessCall);
|
||||
if(succesCallbackFn){
|
||||
succesCallbackFn();
|
||||
}
|
||||
|
@ -344,6 +348,17 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) {
|
|||
});
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
$.log("user not in cookie");
|
||||
}
|
||||
|
||||
var userLoginForm = $("#user-login-form");
|
||||
|
||||
userLoginForm.validate({
|
||||
|
@ -382,6 +397,7 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) {
|
|||
}
|
||||
if (logged == true) {
|
||||
var user = mapUser(result);
|
||||
|
||||
if (user.passwordChangeRequired()==true){
|
||||
changePasswordBox(true,false,user);
|
||||
return;
|
||||
|
@ -389,10 +405,16 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) {
|
|||
// not really needed as an exception is returned but "ceintures et bretelles" as we said in French :-)
|
||||
if (user.locked()==true){
|
||||
$.log("user locked");
|
||||
displayErrorMessage($.i18n.prop("accout.locked"));
|
||||
displayErrorMessage($.i18n.prop("account.locked"));
|
||||
return
|
||||
}
|
||||
|
||||
// FIXME check validated
|
||||
user.rememberme=window.redbackModel.rememberme;
|
||||
if(user.rememberme){
|
||||
user.password=window.redbackModel.password;
|
||||
}
|
||||
$.log("user.rememberme:"+(user.rememberme));
|
||||
reccordLoginCookie(user);
|
||||
$("#login-link").hide();
|
||||
$("#logout-link").show();
|
||||
|
@ -426,7 +448,7 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) {
|
|||
* @param result
|
||||
*/
|
||||
var completeLoginCallbackFn=function(){
|
||||
$("#modal-login-ok").removeAttr("disabled");
|
||||
$("#modal-login-ok").button("reset");
|
||||
$("#small-spinner").remove();
|
||||
// force current screen reload to consider user karma
|
||||
window.sammyArchivaApplication.refresh();
|
||||
|
@ -512,18 +534,24 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) {
|
|||
*/
|
||||
login=function(){
|
||||
$.log("user.js#login");
|
||||
|
||||
$("#modal-login-err-message").html("");
|
||||
|
||||
var valid = $("#user-login-form").valid();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
$("#modal-login-ok").attr("disabled","disabled");
|
||||
$("#modal-login-ok").button("loading");
|
||||
|
||||
//#modal-login-footer
|
||||
$('#modal-login-footer').append(smallSpinnerImg());
|
||||
|
||||
loginCall($("#user-login-form-username").val(),$("#user-login-form-password").val()
|
||||
var rememberme=($("#user-login-form-rememberme" ).attr('checked')=='checked');
|
||||
$.log("rememberme:"+rememberme);
|
||||
window.redbackModel.rememberme=rememberme;
|
||||
window.redbackModel.password=$("#user-login-form-password").val();
|
||||
|
||||
loginCall($("#user-login-form-username").val(),window.redbackModel.password,rememberme
|
||||
,successLoginCallbackFn,errorLoginCallbackFn,completeLoginCallbackFn);
|
||||
|
||||
}
|
||||
|
@ -532,11 +560,12 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) {
|
|||
* call REST method for login
|
||||
* @param username
|
||||
* @param password
|
||||
* @param rememberme
|
||||
* @param successCallbackFn
|
||||
* @param errorCallbackFn
|
||||
* @param completeCallbackFn
|
||||
*/
|
||||
loginCall=function(username,password,successCallbackFn, errorCallbackFn, completeCallbackFn) {
|
||||
loginCall=function(username,password,rememberme,successCallbackFn, errorCallbackFn, completeCallbackFn) {
|
||||
var url = 'restServices/redbackServices/loginService/logIn';
|
||||
|
||||
$.ajax({
|
||||
|
@ -717,7 +746,7 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) {
|
|||
if (registration==true) {
|
||||
$.log("changePassword#sucess,registration:"+registration);
|
||||
displaySuccessMessage($.i18n.prop('change.password.success.section.title'))
|
||||
loginCall(user.username(), $("#passwordChangeFormNewPassword").val(),successLoginCallbackFn,
|
||||
loginCall(user.username(), $("#passwordChangeFormNewPassword").val(),true,successLoginCallbackFn,
|
||||
function(data){
|
||||
displayRestError(data,"modal-password-change-content");
|
||||
}
|
||||
|
|
|
@ -101,7 +101,6 @@
|
|||
</li>
|
||||
<li>
|
||||
<div class="ui-widget navbar-search">
|
||||
|
||||
<input type="text" class="ui-autocomplete-input search-query" id="quick-search-autocomplete"
|
||||
placeholder="${$.i18n.prop('menu.topbar.quicksearch')}" />
|
||||
</div>
|
||||
|
|
|
@ -41,7 +41,10 @@
|
|||
</form>
|
||||
</div>
|
||||
<div class="modal-footer" id="modal-login-footer">
|
||||
<button class="btn btn-primary" id="modal-login-ok">${$.i18n.prop('login')}</button>
|
||||
<div class="pull-left">
|
||||
<input type="checkbox" id="user-login-form-rememberme">${$.i18n.prop('rememberme')}</input>
|
||||
</div>
|
||||
<button class="btn btn-primary" id="modal-login-ok" data-loading-text="${$.i18n.prop('common.loading')}">${$.i18n.prop('login')}</button>
|
||||
<button class="btn btn-info" id="modal-login-password-reset">${$.i18n.prop('password.reset')}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue