Create user with JS

Enonic version: 6.13.1
OS: Centos 6

I try to create user with this code:
authLib.createUser({
userStore: ‘myuserstore’,
name: username,
displayName: displayName,
email: email,
password: password
});
The user is created successfully, but I can’t log in with that user with the specified password. Is there any encryption method I need to use when specifying password as parameter.

Thanks for any help.

Hi,

The user is - if I’m not totally mistaken here - created without any credentials. To be able to log in, it needs the Admin Console Login role. Verify this in Users admin app. If that role is missing, it needs to be added to the user before it can log in.

I’m using custom user store with Simple ID provider. I create a user with JS:
authLib.createUser({
userStore: ‘myuserstore’,
name: ‘thn’,
displayName: ‘displayName’,
email: ‘[email protected]’,
password: ‘pass’
});

When I try to log in with that user email: ‘[email protected]’,
password: ‘pass’.
It got error message wrong username/password so I think of the passord could be encrypted in some way before it was stored in 6.13.1?
But if I log in with su and change the password again in users admin console. Then I can log in with that user.

Hi,

createUser does not take any parameter ‘password’ (http://repo.enonic.com/public/com/enonic/xp/docs/6.14.0/docs-6.14.0-libdoc.zip!/module-auth.html#.createUser)

You need to call changePassword or generatePassword after the user creation.

2 Likes

This topic was automatically closed after 2 days. New replies are no longer allowed.