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
|
* @param user see user.js
|
||||||
*/
|
*/
|
||||||
reccordLoginCookie=function(user) {
|
reccordLoginCookie=function(user) {
|
||||||
$.cookie('redback_login', ko.toJSON(user));
|
$.cookie('archiva_login', ko.toJSON(user));
|
||||||
};
|
};
|
||||||
|
|
||||||
getUserFromLoginCookie=function(){
|
getUserFromLoginCookie=function(){
|
||||||
return $.parseJSON($.cookie('redback_login'));
|
var cookieContent=$.cookie('archiva_login');
|
||||||
|
$.log("archiva_login cookie content:"+cookieContent);
|
||||||
|
return $.parseJSON(cookieContent);
|
||||||
};
|
};
|
||||||
|
|
||||||
deleteLoginCookie=function(){
|
deleteLoginCookie=function(){
|
||||||
$.cookie('redback_login', null);
|
$.cookie('archiva_login', null);
|
||||||
};
|
};
|
||||||
|
|
||||||
logout=function(doScreenChange){
|
logout=function(doScreenChange){
|
||||||
deleteLoginCookie();
|
//deleteLoginCookie();
|
||||||
|
var user = getUserFromLoginCookie();
|
||||||
|
if(user){
|
||||||
|
user.logged=false;
|
||||||
|
reccordLoginCookie(user);
|
||||||
|
}
|
||||||
$("#login-link").show();
|
$("#login-link").show();
|
||||||
$("#register-link").show();
|
$("#register-link").show();
|
||||||
$("#logout-link").hide();
|
$("#logout-link").hide();
|
||||||
|
|
|
@ -76,6 +76,10 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) {
|
||||||
|
|
||||||
this.modified=ko.observable(false);
|
this.modified=ko.observable(false);
|
||||||
|
|
||||||
|
this.rememberme=false;
|
||||||
|
this.password=null;
|
||||||
|
this.logged=false;
|
||||||
|
|
||||||
this.remove = function() {
|
this.remove = function() {
|
||||||
if (ownerViewModel) {
|
if (ownerViewModel) {
|
||||||
ownerViewModel.users.destroy(this);
|
ownerViewModel.users.destroy(this);
|
||||||
|
@ -142,7 +146,7 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) {
|
||||||
checkCreateAdminLink();
|
checkCreateAdminLink();
|
||||||
checkSecurityLinks();
|
checkSecurityLinks();
|
||||||
}
|
}
|
||||||
loginCall(currentAdminUser.username(), currentAdminUser.password(),onSuccessCall);
|
loginCall(currentAdminUser.username(), currentAdminUser.password(),false,onSuccessCall);
|
||||||
if(succesCallbackFn){
|
if(succesCallbackFn){
|
||||||
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");
|
var userLoginForm = $("#user-login-form");
|
||||||
|
|
||||||
userLoginForm.validate({
|
userLoginForm.validate({
|
||||||
|
@ -382,6 +397,7 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) {
|
||||||
}
|
}
|
||||||
if (logged == true) {
|
if (logged == true) {
|
||||||
var user = mapUser(result);
|
var user = mapUser(result);
|
||||||
|
|
||||||
if (user.passwordChangeRequired()==true){
|
if (user.passwordChangeRequired()==true){
|
||||||
changePasswordBox(true,false,user);
|
changePasswordBox(true,false,user);
|
||||||
return;
|
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 :-)
|
// not really needed as an exception is returned but "ceintures et bretelles" as we said in French :-)
|
||||||
if (user.locked()==true){
|
if (user.locked()==true){
|
||||||
$.log("user locked");
|
$.log("user locked");
|
||||||
displayErrorMessage($.i18n.prop("accout.locked"));
|
displayErrorMessage($.i18n.prop("account.locked"));
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME check validated
|
// FIXME check validated
|
||||||
|
user.rememberme=window.redbackModel.rememberme;
|
||||||
|
if(user.rememberme){
|
||||||
|
user.password=window.redbackModel.password;
|
||||||
|
}
|
||||||
|
$.log("user.rememberme:"+(user.rememberme));
|
||||||
reccordLoginCookie(user);
|
reccordLoginCookie(user);
|
||||||
$("#login-link").hide();
|
$("#login-link").hide();
|
||||||
$("#logout-link").show();
|
$("#logout-link").show();
|
||||||
|
@ -426,7 +448,7 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) {
|
||||||
* @param result
|
* @param result
|
||||||
*/
|
*/
|
||||||
var completeLoginCallbackFn=function(){
|
var completeLoginCallbackFn=function(){
|
||||||
$("#modal-login-ok").removeAttr("disabled");
|
$("#modal-login-ok").button("reset");
|
||||||
$("#small-spinner").remove();
|
$("#small-spinner").remove();
|
||||||
// force current screen reload to consider user karma
|
// force current screen reload to consider user karma
|
||||||
window.sammyArchivaApplication.refresh();
|
window.sammyArchivaApplication.refresh();
|
||||||
|
@ -512,18 +534,24 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) {
|
||||||
*/
|
*/
|
||||||
login=function(){
|
login=function(){
|
||||||
$.log("user.js#login");
|
$.log("user.js#login");
|
||||||
|
|
||||||
$("#modal-login-err-message").html("");
|
$("#modal-login-err-message").html("");
|
||||||
|
|
||||||
var valid = $("#user-login-form").valid();
|
var valid = $("#user-login-form").valid();
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$("#modal-login-ok").attr("disabled","disabled");
|
$("#modal-login-ok").button("loading");
|
||||||
|
|
||||||
//#modal-login-footer
|
//#modal-login-footer
|
||||||
$('#modal-login-footer').append(smallSpinnerImg());
|
$('#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);
|
,successLoginCallbackFn,errorLoginCallbackFn,completeLoginCallbackFn);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -532,11 +560,12 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) {
|
||||||
* call REST method for login
|
* call REST method for login
|
||||||
* @param username
|
* @param username
|
||||||
* @param password
|
* @param password
|
||||||
|
* @param rememberme
|
||||||
* @param successCallbackFn
|
* @param successCallbackFn
|
||||||
* @param errorCallbackFn
|
* @param errorCallbackFn
|
||||||
* @param completeCallbackFn
|
* @param completeCallbackFn
|
||||||
*/
|
*/
|
||||||
loginCall=function(username,password,successCallbackFn, errorCallbackFn, completeCallbackFn) {
|
loginCall=function(username,password,rememberme,successCallbackFn, errorCallbackFn, completeCallbackFn) {
|
||||||
var url = 'restServices/redbackServices/loginService/logIn';
|
var url = 'restServices/redbackServices/loginService/logIn';
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
@ -717,7 +746,7 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) {
|
||||||
if (registration==true) {
|
if (registration==true) {
|
||||||
$.log("changePassword#sucess,registration:"+registration);
|
$.log("changePassword#sucess,registration:"+registration);
|
||||||
displaySuccessMessage($.i18n.prop('change.password.success.section.title'))
|
displaySuccessMessage($.i18n.prop('change.password.success.section.title'))
|
||||||
loginCall(user.username(), $("#passwordChangeFormNewPassword").val(),successLoginCallbackFn,
|
loginCall(user.username(), $("#passwordChangeFormNewPassword").val(),true,successLoginCallbackFn,
|
||||||
function(data){
|
function(data){
|
||||||
displayRestError(data,"modal-password-change-content");
|
displayRestError(data,"modal-password-change-content");
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,6 @@
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<div class="ui-widget navbar-search">
|
<div class="ui-widget navbar-search">
|
||||||
|
|
||||||
<input type="text" class="ui-autocomplete-input search-query" id="quick-search-autocomplete"
|
<input type="text" class="ui-autocomplete-input search-query" id="quick-search-autocomplete"
|
||||||
placeholder="${$.i18n.prop('menu.topbar.quicksearch')}" />
|
placeholder="${$.i18n.prop('menu.topbar.quicksearch')}" />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -41,7 +41,10 @@
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer" id="modal-login-footer">
|
<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>
|
<button class="btn btn-info" id="modal-login-password-reset">${$.i18n.prop('password.reset')}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue