From: Olivier Lamy Date: Fri, 23 Nov 2012 09:34:06 +0000 (+0000) Subject: [MRM-1708] When using LDAP, users can still edit their details upon login. X-Git-Tag: archiva-1.4-M4~602 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1fe8a5e4ce893ec664b7cac9d3091c2d3dd5c2b0;p=archiva.git [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 --- diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/SecuritySystemStub.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/SecuritySystemStub.java index a55fb8e77..718b00e88 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/SecuritySystemStub.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/SecuritySystemStub.java @@ -577,4 +577,8 @@ public class SecuritySystemStub return false; } + public boolean userManagerReadOnly() + { + return true; + } } 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 77c07b42d..4b236c0af 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 @@ -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); } diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js index b3e5aa53b..4409b0435 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js @@ -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(); }); diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/redback/login.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/redback/login.html index 6b0650130..15c0397b4 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/redback/login.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/redback/login.html @@ -131,52 +131,58 @@

${$.i18n.prop('password.section.title')}

+ + diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/redback/user-edit.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/redback/user-edit.html index 76e6a38fa..f5051e042 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/redback/user-edit.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/redback/user-edit.html @@ -480,3 +480,5 @@ + + diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/BypassSecuritySystem.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/BypassSecuritySystem.java index dc45bf603..63e11c5b6 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/BypassSecuritySystem.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/BypassSecuritySystem.java @@ -129,4 +129,9 @@ public class BypassSecuritySystem // Always true return true; } + + public boolean userManagerReadOnly() + { + return true; + } }