finishRegistration method
Completes the registration process with the verification code.
On success, updates the session manager and calls onAuthenticated. On failure, transitions to error state with the error message.
Implementation
Future<void> finishRegistration() async {
await _guarded(EmailAuthState.authenticated, null, () async {
final finishRequestToken = _finishRequestToken;
if (finishRequestToken == null) {
throw StateError('No registration request was found to finish.');
}
final authSuccess = await _emailEndpoint.finishRegistration(
registrationToken: finishRequestToken,
password: passwordController.text,
);
await client.auth.updateSignedInUser(authSuccess);
});
}