providers/email library

This library contains the email authentication provider for the Serverpod Idp module.

Classes

AuthSuccess
Response model representing a successful authentication result with all relevant authentication information.
EmailAccount
A fully configured email account to be used for logins.
EmailAccountPasswordResetRequest
Pending email account password reset.
EmailAccountRequest
Pending email account registration.
EmailIdp
Main class for the email identity provider. The methods defined here are intended to be called from an endpoint.
EmailIdpAccountCreationUtil
This class contains utility functions for the email identity provider account creation.
EmailIdpAccountCreationUtilsConfig
Configuration for the EmailIdpAccountCreationUtil class.
EmailIdpAdmin
Collection of email-account admin methods.
EmailIdpAuthenticationUtil
Authentication utilities for the email identity provider.
EmailIdpBaseEndpoint
Base endpoint for email-based accounts.
EmailIdpCompleteAccountCreationResult
The result of the EmailIdpAccountCreationUtil.completeAccountCreation operation.
EmailIdpCompleteAccountRequestResult
The result of the EmailIdpAccountCreationUtil.completeAccountCreation operation.
EmailIdpConfig
Configuration options for the email account module.
EmailIdpConfigFromPasswords
Creates a new EmailIdpConfig instance from keys on the passwords.yaml file.
EmailIdpPasswordResetUtil
Class for handling password reset operations in the email account module.
EmailIdpPasswordResetUtilsConfig
Configuration options for the EmailIdpPasswordResetUtil class.
EmailIdpUtils
Email account management functions.
RateLimit
A rolling rate limit which allows maxAttempts in the most recent timeframe.

Enums

EmailAccountLoginExceptionReason
The reason for why the authentication via email credentials was rejected.
EmailAccountPasswordResetExceptionReason
The reason for why the password reset request was rejected.
EmailAccountRequestExceptionReason
The reason for why the account creation with email request was rejected.

Extensions

EmailAccountExtension on EmailAccount
Extension methods for EmailAccount.
EmailAccountRequestExtension on EmailAccountRequest
Extension methods for EmailAccountRequest.
EmailIdpGetter on AuthServices
Extension to get the EmailIdp instance from the AuthServices.

Functions

defaultVerificationCodeGenerator() String
Returns a secure random string to be used for short-lived verification codes.

Typedefs

AfterAccountCreatedFunction = FutureOr<void> Function(Session session, {required UuidValue authUserId, required String email, required UuidValue emailAccountId, required Transaction? transaction})
Function to be called after a new email account has been created.
OnPasswordResetCompletedFunction = void Function(Session session, {required UuidValue emailAccountId, required Transaction? transaction})
Function to be called after a password reset is successfully completed.
PasswordValidationFunction = bool Function(String password)
Function to be called to check whether a password matches the requirements during registration.
SendPasswordResetVerificationCodeFunction = void Function(Session session, {required String email, required UuidValue passwordResetRequestId, required Transaction? transaction, required String verificationCode})
Function for sending out the verification codes for password reset requests.
SendRegistrationVerificationCodeFunction = void Function(Session session, {required UuidValue accountRequestId, required String email, required Transaction? transaction, required String verificationCode})
Function for sending out the verification codes to verify the email ownership during the initial registration.

Exceptions / Errors

EmailAccountAlreadyRegisteredException
Exception thrown when an email address is already registered.
EmailAccountLoginException
Exception to be thrown if the login via email/password fails.
EmailAccountNotFoundException
Exception thrown for operations on an email address that is not registered.
EmailAccountPasswordResetException
Exception to be thrown if email reset request fails.
EmailAccountRequestAlreadyExistsException
Exception thrown when an email account request already exists.
EmailAccountRequestException
Exception to be thrown if email account creation request fails.
EmailAccountRequestInvalidEmailException
Exception thrown when email address fails email validation.
EmailAccountRequestInvalidVerificationCodeException
Exception thrown when trying to verify an email account with an invalid verification code.
EmailAccountRequestNotFoundException
Exception thrown when trying to complete inexistent email account requests.
EmailAccountRequestNotVerifiedException
Exception thrown when trying to complete a non-verified account request.
EmailAccountRequestServerException
Base exception for all account request related errors.
EmailAccountRequestVerificationCodeAlreadyUsedException
Exception thrown when trying to verify an email account request with a verification code that has already been used.
EmailAccountRequestVerificationExpiredException
Exception thrown when trying to complete an email request that is expired.
EmailAccountRequestVerificationTooManyAttemptsException
Exception thrown when trying to verify an email account too many times.
EmailAuthenticationInvalidCredentialsException
Exception thrown for login attempts with invalid credentials.
EmailAuthenticationTooManyAttemptsException
Exception thrown for too many login attempts.
EmailLoginServerException
Base exception for all login related errors.
EmailPasswordPolicyViolationException
Exception thrown for operations that violate password policies.
EmailPasswordResetAccountNotFoundException
Exception thrown when requesting password reset for an inexistent account.
EmailPasswordResetEmailNotFoundException
Exception thrown when trying to request a password reset for an inexistent email account.
EmailPasswordResetInvalidVerificationCodeException
Exception thrown when trying to complete a password reset request with an invalid verification code.
EmailPasswordResetNotVerifiedException
Exception thrown when trying to validate a password reset request with a set password token that has not been set.
EmailPasswordResetPasswordPolicyViolationException
Exception thrown when trying to complete a password reset request with a password that violates the password policy.
EmailPasswordResetRequestExpiredException
Exception thrown when trying to complete an expired password reset request.
EmailPasswordResetRequestNotFoundException
Exception thrown when trying to complete an inexistent password reset request.
EmailPasswordResetServerException
Base exception for all password reset related errors.
EmailPasswordResetTooManyAttemptsException
Exception thrown when trying to request a password reset too many times.
EmailPasswordResetTooManyVerificationAttemptsException
Exception thrown when trying to complete the password reset request too many times.
EmailPasswordResetVerificationCodeAlreadyUsedException
Exception thrown when trying to validate a password reset verification code that has already been used.
EmailServerException
Base exception for all email related errors.