User authentication
Introduction
This topic guide explains all the steps required to add user authentication to your app. In case you didn't add user registration functionality to your application project yet, please follow the steps in the User registration registration topic guide.
Get registered profiles
The ReactNative SDK provides a function getUserProfiles to get all registered profiles on the device. You will need to use these to authenticate a profile with the SDK.
Authenticate a registered user
Once a user has been registered, it can be logged in using the authenticateUser method. This method takes the profileId of an already registered user and an optional authenticatorId, returning a promise. You can find out which authenticators are available by calling the getRegisteredAuthenticators method passing in the profileId. After starting user authentication the app needs to handle certain events sent by the SDK. Event listeners will need to be set up for PinAuthenticationEvent
before starting authentication, using the addEventListener method. The SDK expects certain input depending on what kind of authentication was started before it will resolve or reject. The events sent by the SDK indicate what kind of input it is expecting.
Authenticate with pin
When authenticating with pin, you will need to handle the PinAuthenticationEvent
. You can listen for this events and handle it as follows.
During pin authentication you should communicate the pin to the SDK using the submitPin method or cancel it using the cancelPinAuthentication method. Please note that the submitPin method expects you to specify for what kind of flow you are submiting the pin. Note that canceling the pin authentication will result in the promise from authenticateUser()
rejecting. You can use that to handle any logic for your app.
If authentication was succesfull, the SDK will resolve the promise from authenticateUser()
. It will also send a PinAuthenticationCloseEvent
event.
PinAuthenticationEvent | Description |
---|---|
PinAuthenticationOpenEvent | Sent when the SDK is ready to receive a pin for authentication. |
PinAuthenticationCloseEvent | Sent by the SDK when it has finished authentication. |
IncorrectPinEvent | Sent by the SDK when it has received an incorrect pin. |