Lucho
Lucho•2mo ago

Zitadel action user register

Hi, I want to use a Zitadel Action to add a user role automatically after registration. I configured my setup according to this guide: https://zitadel.com/docs/guides/manage/customize/behavior The project is granted to the default organization. I used "Internal Authentication" as a Flow Type and the name of the action "addGrant" is the same as the function name. However, when I register I get: rawMessage":"Errors.User.GrantRequired
ZITADEL Docs
In this guide, you will create a ZITADEL action.
No description
19 Replies
Rajat
Rajat•2mo ago
hey @Lucho thanks for your question and welcome to the server, may I know what version are you on (upper right default settings) and do you already have a role ORG_OWNER added?
Lucho
LuchoOP•2mo ago
Hi @Rajat, thank you. Version v4.2.2 and I also added another ORG_OWNER.
No description
Rajat
Rajat•2mo ago
hey @Lucho did anything changed after adding org_owner?
Lucho
LuchoOP•2mo ago
No, unfortunately not: "error":{"name":"ConnectError","rawMessage":"Errors.User.GrantRequired.. Any idea how I can debug this? Maybe I use the wrong project/resourceId?
Rajat
Rajat•2mo ago
hey @Lucho pls check if your projecttID that you are passing in the action matches with the correct actual project
Lucho
LuchoOP•2mo ago
In the placeholder it states: projectID: '<the projects resource ID>', so I assume I have to put the resource ID of the project, which I did. It is a granted project. Do I have to define the action at the project host or at the organization level?
Rajat
Rajat•2mo ago
hey @Lucho good morning, I just tried running this action and it seems to work! this is my script
/**
* Add a usergrant to a new created/registered user
*
* Flow: Internal Authentication or External Authentication, Trigger: Post creation
*
* @param ctx
* @param api
*/
function addGrant(ctx, api) {
api.userGrants.push({
projectID: '299415855849057024',
roles: ['role-from-action']
});
}
/**
* Add a usergrant to a new created/registered user
*
* Flow: Internal Authentication or External Authentication, Trigger: Post creation
*
* @param ctx
* @param api
*/
function addGrant(ctx, api) {
api.userGrants.push({
projectID: '299415855849057024',
roles: ['role-from-action']
});
}
the projectID is the Resource Id mentioned when you click on your project. And the role already existed under roles. I set it under external auth->post creation trigger. Please lmk if this helps
No description
No description
No description
Lucho
LuchoOP•2mo ago
@Rajat Thank you for the detailed explanation! WHat is configured in the postAuth function?
Rajat
Rajat•2mo ago
hey @Lucho that is a seprate action that I wrote, unrelated to this question 😅
Lucho
LuchoOP•2mo ago
@Rajat Should it work the same with Internal Authentication?
Rajat
Rajat•2mo ago
yes it will
Lucho
LuchoOP•3w ago
Hi Rajat, it is still not working. I also found out that the email verify step is not triggered after I set a password.
Rajat
Rajat•3w ago
hey @Lucho if you are using the built in SMTP, that wont work. Its only for testing purposes you may have to setup your own SMTP.
Lucho
LuchoOP•3w ago
we use our own
No description
Lucho
LuchoOP•3w ago
also the test is working and I receive emails but when i do the registration I get an unknown error
No description
Rajat
Rajat•2w ago
hey @Lucho thanks for conforming, seems like a slow SMTP pipeline, I am checking with the team.
Lucho
LuchoOP•2w ago
Thanks. I am wondering how I can even login without confirming the email address. I thought this step is mandatory for new users
Rajat
Rajat•2w ago
hey @Lucho you can update a user and mark its email as verified via the API for now and that should bypass the email verification for now,.
Lucho
LuchoOP•2w ago
Oh sorry, for the confusion. I don't want to skip the email verification. It just looked that the email verification was skipped and the user could login directly. But we had different versions of zitadel login and zitadel db which might confused the system... I will try again

Did you find this page helpful?