]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1708] When using LDAP, users can still edit their details upon login.
authorOlivier Lamy <olamy@apache.org>
Fri, 23 Nov 2012 09:34:06 +0000 (09:34 +0000)
committerOlivier Lamy <olamy@apache.org>
Fri, 23 Nov 2012 09:34:06 +0000 (09:34 +0000)
move useredit detail box to knockout model.

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1412796 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/SecuritySystemStub.java
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/redback/login.html
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/redback/user-edit.html
archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/BypassSecuritySystem.java

index a55fb8e77baaa4fb70f774a95b4143cd2461a146..718b00e88cc684507dc49c21ad69b0450b0bf6d3 100644 (file)
@@ -577,4 +577,8 @@ public class SecuritySystemStub
         return false;
     }
 
+    public boolean userManagerReadOnly()
+    {
+        return true;
+    }
 }
index 77c07b42d053248cd0c38cb31ce351fcac761139..4b236c0afdbcadde6569127652a29901330685a0 100644 (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);
   }
 
 
index b3e5aa53bee501ded36df76c59055f8c34f662fa..4409b04357cb34bd37dc88a790866e39d7425a38 100644 (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();
             });
index 6b0650130d7c1ea42b1769029b56c64415ac6c72..15c0397b4d3130451eb03ecc9c36be0fad34cfee 100644 (file)
     <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="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 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="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 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">
+          <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 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" 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 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 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>
-        </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>
+        </div>
+      </fieldset>
+    </form>
+
+</script>
 
index dc45bf60331b484f977042bc9d85d8a2cf2cf3d5..63e11c5b6fe90f51dc5971792b6142f9842ce22e 100644 (file)
@@ -129,4 +129,9 @@ public class BypassSecuritySystem
         // Always true
         return true;
     }
+
+    public boolean userManagerReadOnly()
+    {
+        return true;
+    }
 }