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
OpenPinAuthenticationEvent
event is broadcasted. - A user needs then to authenticate using the PIN's authentication
acceptAuthenticationRequest
function.- If the PIN was invalid a
NextAuthenticationAttemptEvent
event will be broadcasted. - If the PIN was valid,
ClosePinAuthenticationEvent
andOpenPinRegistrationEvent
events will be broadcasted.
- If the PIN was invalid a
- A user needs to register using a new PIN through the PIN's registration
acceptAuthenticationRequest
function.- If the PIN was invalid a
PinNotAllowedEvent
event will be broadcasted. - If the PIN was valid a
ClosePinRegistrationEvent
will be broadcaster after which thechangePin
function 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");
});