Changing PIN
The Flutter Plugin exposes changePin to allow the currently logged in user to change their PIN. The user is first required to provide their current PIN, before being allowed to create the new PIN. The required flow and their events are described below.
Note
The PIN entered by the user should not be stored on the device or elsewhere in any shape or form. The plugin takes care of this for you in a secure manner.
changePin Events
| event | Reference |
|---|---|
| OpenPinAuthenticationEvent | Authenticate using PIN flow |
| ClosePinAuthenticationEvent | Authenticate using PIN Flow |
| NextAuthenticationAttemptEvent | Authenticate using PIN Flow |
| OpenPinRegistrationEvent | Create PIN |
| PinNotAllowedEvent | Create PIN |
| ClosePinRegistrationEvent | Create PIN |
changePin Flow
The resulting flow to change your PIN will contain the following steps:
- User starts the change PIN flow by calling
Onegini.instance.userClient.changePin(). - An
OpenPinAuthenticationEventevent is broadcasted. - A user needs then to authenticate using the PIN's authentication
acceptAuthenticationRequestfunction.- If the PIN was invalid a
NextAuthenticationAttemptEventevent will be broadcasted. - If the PIN was valid,
ClosePinAuthenticationEventandOpenPinRegistrationEventevents will be broadcasted.
- If the PIN was invalid a
- A user needs to register using a new PIN through the PIN's registration
acceptAuthenticationRequestfunction.- If the PIN was invalid a
PinNotAllowedEventevent will be broadcasted. - If the PIN was valid a
ClosePinRegistrationEventwill be broadcaster after which thechangePinfunction will resolve.
- If the PIN was invalid a
Example code to start the change PIN flow
await Onegini.instance.userClient
.changePin()
.catchError((error) {
print("Pin change failed");
});