verify method
Future<({String challengeToken, bool existingUser})>
verify({
- String? email,
- required UserAuthenticationProvider provider,
- bool? doNotNotify,
Initiates email verification for authentication.
This method starts the email verification process for various authentication providers including password, magic link, and one-time code authentication. It sends a verification email to the user and returns a challenge token that will be used in subsequent authentication steps.
Parameters
email: The email address to verify (optional for some flows)provider: The authentication provider to usedoNotNotify: If true, suppresses sending the verification email
Returns
A Future that resolves to a record containing:
challengeToken: Token to use for subsequent authenticationexistingUser: Whether a user with this email already exists
Throws
HttpExceptionif there's a network errorCalljmpExceptionif the server returns an error
Example
final verification = await calljmp.users.auth.email.verify(
email: 'user@example.com',
provider: UserAuthenticationProvider.emailPassword,
);
if (verification.existingUser) {
print('User exists, can sign in');
} else {
print('New user, will be created');
}
Implementation
Future<({String challengeToken, bool existingUser})> verify({
String? email,
required UserAuthenticationProvider provider,
bool? doNotNotify,
}) => http
.request("${_config.serviceUrl}/users/auth/email/verify")
.use(http.context(_config))
.use(http.access())
.post({
"email": email,
"provider": provider.value,
"doNotNotify": doNotNotify,
})
.json(
(json) => (
challengeToken: json["challengeToken"],
existingUser: json["existingUser"],
),
);