[MRM-1708] When using LDAP, users can still edit their details upon login.

move useredit detail box to knockout model.

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1412796 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-11-23 09:34:06 +00:00
parent d0fe7f5f12
commit 1fe8a5e4ce
6 changed files with 79 additions and 48 deletions

View File

@ -577,4 +577,8 @@ public class SecuritySystemStub
return false;
}
public boolean userManagerReadOnly()
{
return true;
}
}

View File

@ -36,7 +36,7 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,purl) {
* @param ownerViewModel
*/
User=function(username, password, confirmPassword,fullName,email,permanent,validated,timestampAccountCreation,
timestampLastLogin,timestampLastPasswordChange,locked,passwordChangeRequired,ownerViewModel) {
timestampLastLogin,timestampLastPasswordChange,locked,passwordChangeRequired,ownerViewModel,readOnly) {
var self=this;
// Potentially Editable Field.
this.username = ko.observable(username);
@ -76,6 +76,8 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,purl) {
this.modified=ko.observable(false);
this.readOnly=readOnly;
this.rememberme=false;
this.logged=false;
@ -647,6 +649,10 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,purl) {
$("#modal-password-change").focus();
}
EditUserDetailViewModel=function(user){
this.user=user;
}
/**
* display modal box for updating current user details
*/
@ -678,9 +684,17 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,purl) {
});
}
var currentUser = getUserFromLoginCookie();
$("#modal-user-edit").find("#username").html(currentUser.username);
/*$("#modal-user-edit").find("#username").html(currentUser.username);
$("#modal-user-edit").find("#fullname").val(currentUser.fullName);
$("#modal-user-edit").find("#email").val(currentUser.email);
$("#modal-user-edit").find("#email").val(currentUser.email);*/
$("#modal-user-edit-content" ).attr("data-bind",'template: {name:"modal-user-edit-tmpl"}');
var editUserDetailViewModel=new EditUserDetailViewModel(currentUser);
ko.applyBindings(editUserDetailViewModel,$("#modal-user-edit-content").get(0));
//$("#modal-user-edit-content").html($("#modal-user-edit-tmpl").tmpl({user: currentUser} ));
window.modalEditUserBox.modal('show');
$("#user-edit-form").validate({
rules: {
@ -710,7 +724,6 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,purl) {
dataType: 'json',
success: function(result) {
var created = result;
// FIXME i18n
if (created == true) {
displaySuccessMessage( $.i18n.prop("user.details.updated"));
window.modalEditUserBox.modal('hide');
@ -796,7 +809,7 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,purl) {
mapUser=function(data) {
return new User(data.username, data.password, null,data.fullName,data.email,data.permanent,data.validated,
data.timestampAccountCreation,data.timestampLastLogin,data.timestampLastPasswordChange,
data.locked,data.passwordChangeRequired,self);
data.locked,data.passwordChangeRequired,self,data.readOnly);
}

View File

@ -121,6 +121,7 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) {
}
editUserBox=function(user) {
$.log("editUserBox");
clearUserMessages();
activateUsersEditTab();
var mainContent = $("#main-content");
@ -144,7 +145,7 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) {
mainContent.find("#users-view-tabs-li-user-edit a").html($.i18n.prop("edit"));
mainContent.find("#user-create #user-create-form-cancel-button").on("click", function(e) {
mainContent.find("#user-create" ).find("#user-create-form-cancel-button").on("click", function(e) {
e.preventDefault();
activateUsersGridTab();
});

View File

@ -131,52 +131,58 @@
<h3>${$.i18n.prop('password.section.title')}</h3>
</div>
<div class="modal-body" id="modal-user-edit-content">
<form id="user-edit-form" class="form-horizontal">
<div id="modal-user-edit-err-message" class="alert-message error" style="display:none"></div>
<fieldset>
<div class="control-group">
<label class="control-label" for="username">${$.i18n.prop('username')}</label>
<div class="controls" id="username-div">
<span class="uneditable-input" id="username"></span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="fullname">${$.i18n.prop('full.name')}</label>
<div class="controls">
<input type="text" id="fullname" name="fullname" size="30" class="required"/>
</div>
</div>
<div class="control-group">
<label class="control-label" for="email">${$.i18n.prop('email.address')}</label>
<div class="controls">
<input type="text" id="email" name="email" size="30" class="required email"/>
</div>
</div>
<div class="control-group" id="user-edit-form-current-password-div">
<label class="control-label" for="userEditFormCurrentPassword">${$.i18n.prop('password.existing')}</label>
<div class="controls">
<input type="password" id="userEditFormCurrentPassword" name="userEditFormCurrentPassword" class="required" value=""/>
</div>
</div>
<div class="control-group">
<label class="control-label" for="userEditFormNewPassword">${$.i18n.prop('password.new')}</label>
<div class="controls">
<input type="password" id="userEditFormNewPassword" name="userEditFormNewPassword" class="" value=""/>
</div>
</div>
<div class="control-group">
<label class="control-label" for="userEditFormNewPasswordConfirm">${$.i18n.prop('password.new.confirm')}</label>
<div class="controls">
<input type="password" id="userEditFormNewPasswordConfirm" name="userEditFormNewPasswordConfirm" class="" value=""/>
</div>
</div>
</fieldset>
</form>
</div>
<div class="modal-footer" id="modal-user-edit-footer">
<button class="btn primary" onclick="return" id="modal-user-edit-ok">${$.i18n.prop('ok')}</button>
</div>
</div>
<script type="text/html" id="modal-user-edit-tmpl">
<form id="user-edit-form" class="form-horizontal">
<div id="modal-user-edit-err-message" class="alert-message error" style="display:none"></div>
<fieldset>
<div class="control-group">
<label class="control-label" for="username">${$.i18n.prop('username')}</label>
<div class="controls" id="username-div">
<span class="uneditable-input" data-bind="text: user.username"></span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="fullname">${$.i18n.prop('full.name')}</label>
<div class="controls">
<input type="text" id="fullname" name="fullname" size="30" class="required" data-bind="value: user.fullName"/>
</div>
</div>
<div class="control-group">
<label class="control-label" for="email">${$.i18n.prop('email.address')}</label>
<div class="controls">
<input type="text" id="email" name="email" size="30" class="required email" data-bind="value: user.email"/>
</div>
</div>
<div class="control-group" id="user-edit-form-current-password-div">
<label class="control-label" for="userEditFormCurrentPassword">${$.i18n.prop('password.existing')}</label>
<div class="controls">
<input type="password" id="userEditFormCurrentPassword" name="userEditFormCurrentPassword" class="required" value=""/>
</div>
</div>
<div class="control-group">
<label class="control-label" for="userEditFormNewPassword">${$.i18n.prop('password.new')}</label>
<div class="controls">
<input type="password" id="userEditFormNewPassword" name="userEditFormNewPassword" class="" value=""/>
</div>
</div>
<div class="control-group">
<label class="control-label" for="userEditFormNewPasswordConfirm">${$.i18n.prop('password.new.confirm')}</label>
<div class="controls">
<input type="password" id="userEditFormNewPasswordConfirm" name="userEditFormNewPasswordConfirm" class="" value=""/>
</div>
</div>
</fieldset>
</form>
</script>

View File

@ -129,4 +129,9 @@ public class BypassSecuritySystem
// Always true
return true;
}
public boolean userManagerReadOnly()
{
return true;
}
}