0

Is there a way to get the user Id from the Verification?

I am implementing a custom self registration process in an Experience Site, user fill up a form including the password and then they are redirected to the Verify Identity Page.

To do so, we are using first:

System.UserManagement.initSelfRegistration(Auth.VerificationMethod.EMAIL, User); ( )

to start a Verification Challenge, then in the Verify Identity

we use System.UserManagement.verifySelfRegistration (https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_System_UserManagement.htm#apex_System_UserManagement_verifySelfRegistration)

It works fine and the user is created, however we would like to set the Password filled in the initial form, to do so I can only do it after the user has been inserted because i need the user Id (System.setPassword(userId, password) )and that only happens after verifySelfRegistration is executed, however it doesnt return the Id of the inserted user. Is there a way to set the password before verifySelfRegistration inserts the User? Or to get the User Id from verifySelfRegistration? This method returns a an Auth Verification result object but there is no field in that object that contains the Id of the new user ( https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Auth_VerificationResult.htm)

in theory the user is automatically logged in after the execution, however if I execute UserInfo.getUserId() after verifySelfRegistration I still get the ID of the Guest User instead of the User that just registered, thought about querying the user with the name and email fields, however doesnt seem like the cleanest solution

0

You must log in to answer this question.