X-Git-Url: https://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=238cc7ef106d6e1be77eaa5ebfd90a1f52535a1a;hb=06f80b7b50619d1c997e2660eddb32a584cfc8a8;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..238cc7ef1 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,60 @@ qx.Class.define("org.argeo.security.ria.components.PasswordCredentialImpl", { events : { "modified" : "qx.event.type.Event" }, + properties : { + valid : { + 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(){ this.base(arguments); 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.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.form.TextField(), {flex:2}); + 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 encoded = null; + if(this.pass1.getValue() != ""){ + var encoder = this.getEncoderCallback(); + encoded = encoder(this.pass1.getValue()); + } + return encoded; + }, + clear : function(){ + this.pass1.setValue(""); + this.pass2.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); + }else{ + this.setValid(true); + } + return this.getValid(); + }, setEditMode : function(editMode){return true;} } }); \ No newline at end of file