X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=security%2Fruntime%2Forg.argeo.security.ria%2Fsrc%2Fargeo-ria-lib%2Fsecurity%2Fclass%2Forg%2Fargeo%2Fsecurity%2Fria%2Fcomponents%2FPasswordCredentialImpl.js;h=48723506ef7e71a8866dd3fa82161cefe34bb4da;hb=9b6a0645e8e964fd7bb04a63ddebbf2f14bd7779;hp=238cc7ef106d6e1be77eaa5ebfd90a1f52535a1a;hpb=06f80b7b50619d1c997e2660eddb32a584cfc8a8;p=lgpl%2Fargeo-commons.git diff --git a/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/components/PasswordCredentialImpl.js b/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/components/PasswordCredentialImpl.js index 238cc7ef1..48723506e 100644 --- a/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/components/PasswordCredentialImpl.js +++ b/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/components/PasswordCredentialImpl.js @@ -8,6 +8,9 @@ qx.Class.define("org.argeo.security.ria.components.PasswordCredentialImpl", { valid : { init : false }, + selfEdition : { + init : false + }, encoderCallback : { init : function(string){ var encoderShort = org.argeo.ria.util.Encoder; @@ -17,13 +20,23 @@ qx.Class.define("org.argeo.security.ria.components.PasswordCredentialImpl", { } }, - construct : function(){ + construct : function(selfEdition){ this.base(arguments); + if(selfEdition){ + this.setSelfEdition(selfEdition); + } this.setLayout(new qx.ui.layout.HBox(5, "center")); - this.add(new qx.ui.basic.Label("Password"), {flex:1}); + this.getLayout().setAlignY("middle"); + if(this.getSelfEdition()){ + this.oldPass = new qx.ui.form.PasswordField(); + this.add(new qx.ui.basic.Label("Old"), {flex:1}); + this.add(this.oldPass, {flex:2}); + this.oldPass.addListener("changeValue", function(){this.fireEvent("modified");}, this); + } + this.add(new qx.ui.basic.Label((selfEdition?"New":"Password")), {flex:1}); this.pass1 = new qx.ui.form.PasswordField(); this.add(this.pass1, {flex:2}); - this.add(new qx.ui.basic.Label("Confirm Password"), {flex:1}); + this.add(new qx.ui.basic.Label((selfEdition?"Confirm":"Confirm Password")), {flex:1}); this.pass2 = new qx.ui.form.PasswordField(); this.add(this.pass2, {flex:2}); this.pass1.addListener("changeValue", function(){this.fireEvent("modified");}, this); @@ -36,24 +49,31 @@ qx.Class.define("org.argeo.security.ria.components.PasswordCredentialImpl", { return this; }, getData : function(format){ - var encoded = null; - if(this.pass1.getValue() != ""){ - var encoder = this.getEncoderCallback(); + var encoder = this.getEncoderCallback(); + var encoded = null; + if(this.pass1.getValue() != null && this.pass1.getValue() != ""){ encoded = encoder(this.pass1.getValue()); } + if(this.getSelfEdition() && encoded && this.oldPass.getValue()!=""){ + return {oldPass:encoder(this.oldPass.getValue()), newPass:encoded}; + } return encoded; }, clear : function(){ this.pass1.setValue(""); - this.pass2.setValue(""); + this.pass2.setValue(""); + if(this.getSelfEdition()){ + this.oldPass.setValue(""); + } }, validate : function(){ - if(this.pass1.getValue() != this.pass2.getValue() || this.pass1.getValue() == ""){ - // TODO WHEN TESTING 0.8.3 - //this.pass1.setValid(false); - //this.pass2.setValid(false); - this.setValid(false); + if(this.pass1.getValue() != this.pass2.getValue()){ + this.pass1.setValid(false); + this.pass2.setValid(false); + this.setValid(false); }else{ + this.pass1.setValid(true); + this.pass2.setValid(true); this.setValid(true); } return this.getValid();