Adding end users while INSIDE mobile app

Hi there.


QUESTION: is it possible for the admin user to be able to add end users from INSIDE a mobile application? If so how would I go about this?


In case I wasn't clear what I'm looking for is: the admin user to be able to load up the app, log into the app and then be able to add new end users.


Kind Regards

Hi Shaan,

Yes that should be possible, when the mobile application has an active internet connection.

You can utilize the OutSystems Users API from to pro grammatically create users.

Authorize the relevant app, or screens with a Admin role. Do also a check of this role on any server actions that you develop that in the end creates users.

Regards,

Daniel

Hi Daniel 

Do I need to tick every single server action box? (example pic attached)

Kind Regards

Hi Shaan,

If you only want to create a user then a reference User_Create and EncryptPassword are needed. You have to encrypt the password and set it on the User record that you pass as input to User_Create.

Regards,

Daniel


Hi I've attached my oml file. 

When I fill in the user details and press save it appears to save the user because when I fill in the details again it says "user with this username already exists" but when I try to log in with these same user details it doesn't let me log in. 

What is the issue here?

Kind Regards

Solution

Hi Shaan,

On thing I notice, you are not correctly setting the password attribute value.

You cannot just pas the password as typed by the user. You have to encrypt it.

To do that:

1. Add dependency to Users Encrypt Password:

2. Add a calll to EncryptPassword after the If in your SaveUser screen action


 3. Add an assign widget before the CreateUser entity action in your SaveUser screen action, and update the password parameter with the encrypted value


Your action flow should look like this:
     


Ideally, following best practice you should move the two server actions into one server action and call that from your SaveUsers screen action.


Regards,

Daniel


Solution

Daniël Kuhlmann wrote:

Hi Shaan,

On thing I notice, you are not correctly setting the password attribute value.

You cannot just pas the password as typed by the user. You have to encrypt it.

To do that:

1. Add dependency to Users Encrypt Password:

2. Add a calll to EncryptPassword after the If in your SaveUser screen action


 3. Add an assign widget before the CreateUser entity action in your SaveUser screen action, and update the password parameter with the encrypted value


Your action flow should look like this:
     


Ideally, following best practice you should move the two server actions into one server action and call that from your SaveUsers screen action.


Regards,

Daniel


Thank you Daniel.


When I create the new user and log in with the credentials it doesn't show me their name in this section(pic attached) like it does with other users.

Any idea why that could be?

Kind Regards

Hi Shaan,

First things first, did my suggestion solve your problem of not being able to login? If so, then please mark my answer as a solution.

Ideally you ask another problem in another new post. But here is the answer:

Your user "Name" input is bound to local variable Name not to Username.Name

Thus when creating the user record, Name attribute of the Username record is not filled.

So to fix this, change the Variable property to Username.name

Regards,

Daniel

Daniël Kuhlmann wrote:

Hi Shaan,

First things first, did my suggestion solve your problem of not being able to login? If so, then please mark my answer as a solution.

Ideally you ask another problem in another new post. But here is the answer:

Your user "Name" input is bound to local variable Name not to Username.Name

Thus when creating the user record, Name attribute of the Username record is not filled.

So to fix this, change the Variable property to Username.name

Regards,

Daniel

I changed the variable property like you said but it still won't display anything in the userinfo block when I log in with the newly created user(OML attached).

Kind Regards


Hi again,

I cannot 1CP your module and debug as I miss 3 dependent modules, but you should debug the following action:

The GetUserNameFromServer should give back the username,


You can also query the Users entity and check if the name is correctly stored, because when that is still not working (remember all the users you added without name) then of course no name will be displayed

Regards,

Daniel