Skip to Content (Press Enter)
OutSystems.com
Personal Edition
Community
Support
Training
Training
Online Training
Developer Schools
Boot Camps
Certifications
Tech Talks
Documentation
Documentation
Overview
ODC
O11
Forums
Forge
Get Involved
Get Involved
Jobs
Ideas
Members
Mentorship
User Groups
Platform
Platform
ODC
O11
Search in OutSystems
Log in
Get Started
Back to Forums
PBrito
168
Views
4
Comments
Assigning a role to a user on runtime
Question
Roles
Hi all,
I wanted to know if its possible to create a user and assign a role to said user, all during runtime?
João Rosado
Staff
Hi Pedro,
Check the
How2UserRegistration
application in the forge.
It's an example on how to do exaclty what you want.
Not sure if I like the GrantUserManagerRole/RevokeUserManagerRole in the example though.
You don't need that if you are creating a user when your current user already has permissions to do it. (The example is for self registration and the User_Create action from users makes a permission check)
The only thing the User_Create is to check for existing username and call the entity CreateUser action.
It's probably better to do that directly instead of giving the UserManagerRole temporarily to a new user just to be able to call User_Create.
Regards,
João Rosado
J.
MVP
In short, yes :)
PBrito
Man this what I'm loving about Outsystems, there's a module for everything! :)
Kilian Hekhuis
MVP
For those finding this topic and not wanting to check the forge application, here are the steps:
1) Create a user by referencing the User system table and call the CreateUser entity action (filling in the right attributes etc. Use the
EncryptPassword
function from the Users eSpace to encrypt the password);
2) Grant roles to that user by calling the appropriate GrantXxxRole actions (where Xxx is the role name). You can find these below the Roles themselves. (Unfortunately, there's no generic action that lets you grant a role based purely on its name.)
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
See the full guidelines
Loading...