EmailOtpIdpBaseEndpoint class abstract

Base endpoint for email-based accounts with passwordless login, where users sign in or sign up with a one-time password (OTP) sent to their email.

Includes all methods of EmailIdpBaseEndpoint, so users can still sign in with their password. Exposing this endpoint instead of EmailIdpBaseEndpoint makes the client show the passwordless sign-in widget.

The codes are sent with EmailIdpConfig.sendOtpLoginVerificationCode, which ServerpodCloudEmailIdpConfig sets. If it is not set, they are sent with EmailIdpConfig.sendRegistrationVerificationCode instead, see EmailIdpConfig.sendOtpLoginVerificationCode for when that is not suitable.

Subclass this in your own application to expose an endpoint including all methods. For further details see https://docs.serverpod.dev/concepts/working-with-endpoints#inheriting-from-an-endpoint-class-marked-abstract

Inheritance

Constructors

EmailOtpIdpBaseEndpoint()

Properties

emailIdp → EmailIdp
Accessor for the configured Email Idp instance. By default this uses the global instance configured in AuthServices.
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
logSessions → bool
States if Sessions should be logged for this endpoint. Defaults to true, override to change.
no setterinherited
moduleName → String?
The name of the current module, or null for the main server.
no setterinherited
name → String
The name of this Endpoint. It will be automatically generated from the name of the class (excluding any Endpoint suffix).
no setterinherited
pod → Serverpod
The ServerPod this Endpoint is running on.
no setterinherited
requiredScopes → Set<Scope>
List of Scopes that are required to access this Endpoint. Override this getter to setup custom requirements.
no setterinherited
requireLogin → bool
States if the Endpoint only should accept users that are authenticated. Default value is false, override to change.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
sendAsRaw → bool
If true, returned value from methods will be sent sent to the client as raw data without any formatting. One use case is to return data through a non-api call. Defaults to false, override to change. If used, the endpoint method is responsible for correctly setting the contentType of the http response (defaults to text/plain).
no setterinherited
server → Server
The Server this Endpoint is running on.
no setterinherited

Methods

finishOtpLogin(Session session, {required String otpLoginToken}) → Future<AuthSuccess>
Completes a passwordless login for an existing account and returns a new session.
finishOtpRegistration(Session session, {required String otpLoginToken, String? password}) → Future<AuthSuccess>
Completes a passwordless login for an email without an account, by creating a new auth user with a profile and attaching the verified email to it.
finishPasswordReset(Session session, {required String finishPasswordResetToken, required String newPassword}) → Future<void>
Completes a password reset request by setting a new password.
inherited
finishRegistration(Session session, {required String registrationToken, required String password}) → Future<AuthSuccess>
Completes a new account registration, creating a new auth user with a profile and attaching the given email account to it.
inherited
hasAccount(Session session) → Future<bool>
Returns the method value for each connected Idp subclass if the current session is authenticated and if the user has an account connected to the Idp.
inherited
initialize(Server server, String name, String? moduleName) → void
Initializes the endpoint with the current Server. Typically, this is done from generated code.
inherited
login(Session session, {required String email, required String password}) → Future<AuthSuccess>
Logs in the user and returns a new session.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
startOtpLogin(Session session, {required String email}) → Future<UuidValue>
Starts a passwordless login by sending a one-time password to email.
startPasswordReset(Session session, {required String email}) → Future<UuidValue>
Requests a password reset for email.
inherited
startRegistration(Session session, {required String email}) → Future<UuidValue>
Starts the registration for a new user account with an email-based login associated to it.
inherited
toString() → String
A string representation of this object.
inherited
verifyOtpLoginCode(Session session, {required UuidValue otpLoginRequestId, required String verificationCode}) → Future<EmailAccountOtpVerificationResult>
Verifies a one-time password and returns a token to complete the login.
verifyPasswordResetCode(Session session, {required UuidValue passwordResetRequestId, required String verificationCode}) → Future<String>
Verifies a password reset code and returns a finishPasswordResetToken that can be used to finish the password reset.
inherited
verifyRegistrationCode(Session session, {required UuidValue accountRequestId, required String verificationCode}) → Future<String>
Verifies an account request code and returns a token that can be used to complete the account creation.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited