Account Recovery
Learn how to set up account recovery on your website frontend
Account Recovery automates the process of re-authenticating users who forgot or had an issue with their password or existing device.
Prerequisites
To get the most out of this guide, make sure to do the following tasks first:
- Complete the backend integrations (see Build Server-Side Endpoints).
- Complete the Login integration (see Login).
The instructions on this page assume you have already installed and referenced the OwnID SDK as described in Steps 1 and 2 of Login.
Integrating Account Recovery
Implement the account recovery event handlers, and OwnID integration on the desired page.
Add the Widget to your Registration Form
The SDK recover method is used to integrate with the account recovery journey. It references the field Ids in your existing recovery form. It also renders the OwnId widget automatically referencing your field Ids to calculate its position in the DOM.
The sample recover forms in the snippets below are vanilla examples, shown here only to confirm the implementation pattern of form fields in SDK methods.
Implement the recover Method
In the ownid method:
-
Enter “recover” for the method name.
-
Assign the form field (as a DOM element) you use as the login id to the
loginIdField
parameter. -
Assign the the same field (as a DOM element) you use as the login id to the
targetIdField
parameter. -
Assign an error function as desired in the
onError
parameter. -
Configure the
onLogin
event to copy thedata.token
object locally. Thedata.token
is the value generated by thegetSessionByLoginId
endpoint and you should use it to set a user session or exchange it for a session token.
Session identifier can be ANY data Object
As noted in the Login integration, the session identifier can be any unique data object, even though we’re calling it a ‘token’. We only pass it right back to you so you’re able to associate a request with an active session.
- Redirect the user to the appropriate landing page at your discretion.
Use the code snippets below, and check the embedded comments, to model your implementation of the submit handler and the SDK recover method.
That’s it!
You’ve implemented the frontend functionality required for the user to recover their account.
If you’re ready to deploy your integration, make sure to read the Pre-Deployment Checklist before hand!
Select an option below to get to the right place.
Next Steps
Ready to deploy?
Was this page helpful?