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=66e38eacf038897e4db1586e578abe142b83569a;hpb=81579a12a1b3fa8a21e1ad7944e5dccaa8beeadf;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 66e38eacf..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 @@ -4,22 +4,80 @@ qx.Class.define("org.argeo.security.ria.components.PasswordCredentialImpl", { events : { "modified" : "qx.event.type.Event" }, + properties : { + valid : { + init : false + }, + selfEdition : { + init : false + }, + encoderCallback : { + init : function(string){ + var encoderShort = org.argeo.ria.util.Encoder; + return "{SHA}"+encoderShort.base64Encode(encoderShort.hexDecode(encoderShort.hash(string, "sha1"))); + }, + check : "Function" + } + }, - 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.add(new qx.ui.form.TextField(), {flex:2}); - this.add(new qx.ui.basic.Label("Confirm Password"), {flex:1}); - this.add(new qx.ui.form.TextField(), {flex:2}); + 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((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); + this.pass2.addListener("changeValue", function(){this.fireEvent("modified");}, this); + this.pass2.addListener("changeValue", this.validate, this); }, members : { getContainer : function(){ return this; }, - getData : function(format){return true;}, - validate : function(){return true;}, + getData : function(format){ + 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(""); + if(this.getSelfEdition()){ + this.oldPass.setValue(""); + } + }, + validate : function(){ + 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(); + }, setEditMode : function(editMode){return true;} } }); \ No newline at end of file