Apps and development tools - IG User Management
Special featuresInjecting users and groups programatically
The IG user management design uses HDBModel for data storage. Because of this it is quite easy to inject user and groups programatically via HDBModel methods, provided the contentclass names are known.
User documents are of content class "user". A JavaScript object can be passed as custom param to the HDBModel.createContent() method whose properties will be used to fill the items on the created user. Assuming OpenWGA 6.1 with a user management app "users" one could do the following from a separate design:
var usersModel = WGA.design("users").HDBModel;
usersModel.createContent("user", null, {
enabled: true,
username: "NewUser",
customaliases: WGA.createList(["A new user", "Yet another one"]),
email: "newuser@innovationgate.com",
password: WGA.Utils.hashPassword("changeme")
});
The same for a "group":
var usersModel = WGA.design("users").HDBModel;
usersModel.createContent("group", null, {
enabled: true,
groupname: "NewUsers",
members: WGA.createList(["NewUser", "EvenNewerUser"])
});
Some tips around this functionality:
- Use the DB explorer in Admin Client (Menu "Tools") to find out about the item names for diverse user/group fields on existing users and groups.
- Use field "customaliases" instead of "useraliases". The first one is the user entered field. The second one is automatically composed from "customaliases" and other, automatic aliases.
- Use regular TMLScript lists for any list item. Using native JavaScript arrays does not work here.