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%2FUserEditorApplet.js;h=f7fad1df4f3ebc991cdc65837bcb2c8bb0dd0049;hb=06f80b7b50619d1c997e2660eddb32a584cfc8a8;hp=e85b5241093f7c40f1660940160fe230539d3f74;hpb=98715b5696e21fcbc2d49f18f7bfac511569b897;p=lgpl%2Fargeo-commons.git diff --git a/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/UserEditorApplet.js b/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/UserEditorApplet.js index e85b52410..f7fad1df4 100644 --- a/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/UserEditorApplet.js +++ b/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/UserEditorApplet.js @@ -139,8 +139,14 @@ qx.Class.define("org.argeo.security.ria.UserEditorApplet", rolesList : { }, - instanceId : {init:""}, - instanceLabel : {init:"Editor"}, + instanceId : { + init:"", + event : "changeInstanceId" + }, + instanceLabel : { + init:"Editor", + event : "changeInstanceLabel" + }, loaded : { init : false }, @@ -259,10 +265,15 @@ qx.Class.define("org.argeo.security.ria.UserEditorApplet", }else{ user.setRoles([]); } - user.setPassword(this.passPane.getData()); // GO TO AND RETURN FROM SERVER if(user.isCreate()){ + if(!this.passPane.validate()){ + this.error("Warning, passwords differ!"); + return; + } + user.setPassword(this.passPane.getData()); + var create = true; var userExists = false; var req = org.argeo.security.ria.SecurityAPI.getUserExistsService(user.getName()); req.addListener("completed", function(response){ @@ -274,20 +285,45 @@ qx.Class.define("org.argeo.security.ria.UserEditorApplet", this.error("User already exists, choose another name!"); return; } + }else{ + var pass = this.passPane.getData(); + if(pass != null && !this.passPane.validate()){ + this.error("Warning, passwords differ!"); + return; + } } - var userService = user.getSaveService(); - userService.send(); - userService.addListener("completed", function(response){ - if(response.getContent().status && response.getContent().status == "ERROR"){ - return; + this.passPane.clear(); + var saveCompletedCallback = qx.lang.Function.bind(function(){ + if(create){ + this.setInstanceLabel("User " + user.getName()); + this.setInstanceId(user.getName()); } this._setGuiInCreateMode(false); - user.load(response.getContent(), "json"); this.partialRefreshUser(user, ["details","natures"]); this.setModified(false); this.getViewSelection().triggerEvent(); - this.fireDataEvent("savedUser", user); + this.fireDataEvent("savedUser", user); }, this); + var userService = user.getSaveService(); + userService.addListener("completed", function(response){ + if(response.getContent().status && response.getContent().status == "ERROR"){ + return; + } + user.load(response.getContent(), "json"); + if(pass!=null){ + var passService = org.argeo.security.ria.SecurityAPI.getUpdateUserPassService(user.getName(), pass); + passService.addListener("completed", function(response){ + if(response.getContent().status){ + this.info(response.getContent().message); + } + saveCompletedCallback(); + }, this); + passService.send(); + }else{ + saveCompletedCallback(); + } + }, this); + userService.send(); }, _addNatureTab : function(natureClass, natureData, select){