Various tweaks, everything is usable except password settings for the moment.
[lgpl/argeo-commons.git] / security / runtime / org.argeo.security.ria / src / argeo-ria-lib / security / class / org / argeo / security / ria / model / User.js
index 4595fbcb5b103829aa9487fff848afbe0253eb10..64ba63e4c898c95c3b13854e6b5b8dde06cfc807 100644 (file)
@@ -13,22 +13,32 @@ qx.Class.define("org.argeo.security.ria.model.User", {
                },\r
                rawData : {\r
                        \r
+               },\r
+               create : {\r
+                       check : "Boolean",\r
+                       init : true\r
                }\r
        },\r
        construct : function(){\r
                this.base(arguments);\r
                this.setRoles([]);\r
                this.setNatures([]);\r
+               this.setRawData({"password":"{SHA}ieSV55Qc+eQOaYDRSha/AjzNTJE="});\r
        },\r
        members : {\r
                load : function(data, format){\r
+                       this.setCreate(false);\r
                        this.setName(data.username);\r
                        this.setRoles(data.roles);\r
                        this.setNatures(data.userNatures);\r
                        this.setRawData(data);\r
                },\r
                getSaveService : function(){\r
-                       var userService = org.argeo.security.ria.SecurityAPI.getUpdateUserService(this.toJSON());\r
+                       if(this.isCreate()){\r
+                               var userService = org.argeo.security.ria.SecurityAPI.getCreateUserService(this.toJSON());                       \r
+                       }else{\r
+                               var userService = org.argeo.security.ria.SecurityAPI.getUpdateUserService(this.toJSON());                               \r
+                       }\r
                        userService.addListener("completed", function(response){\r
                                if(!response || !response.username) return;\r
                                this.load(response.getContent(), "json");\r