Auth class
The Nhost Auth service.
Supports user authentication, MFA, OTP, and various user management functions.
See https://docs.nhost.io/reference/sdk/authentication for more info.
Constructors
Properties
- authenticationState → AuthenticationState
-
Whether a user is logged in, not logged in, or if a login is in process.
no setter
- currentUser → User?
-
Currently logged-in user, or
null
if unauthenticated.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- jwt → String?
-
The currently logged-in user's Json Web Token, or
null
if unauthenticated.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
activate(
String ticket) → Future< void> - Activates a user.
-
addAuthStateChangedCallback(
AuthStateChangedCallback callback) → UnsubscribeDelegate - Add a callback that will be invoked when the service's authentication state changes.
-
addTokenChangedCallback(
TokenChangedCallback callback) → UnsubscribeDelegate - Add a callback that will be invoked when the service's token changes.
-
changeEmail(
String newEmail) → Future< void> - Changes the email address of a logged in user.
-
changePassword(
{required String oldPassword, required String newPassword}) → Future< void> - Changes the password of a logged in user who knows their current password.
-
close(
) → void - Releases the service's resources.
-
completeMfaLogin(
{required String code, required String ticket}) → Future< AuthResponse> - Complete an MFA login using a time-based one-time password.
-
completeOAuthProviderLogin(
Uri redirectUrl) → Future< void> -
Completes an OAuth provider login, given the Nhost OAuth provider's
redirectUrl
. -
confirmEmailChange(
{required String ticket}) → Future< void> - Confirms an email change.
-
confirmPasswordChange(
{required String newPassword, required String? ticket}) → Future< void> - Confirms an password change.
-
disableMfa(
String code) → Future< void> - Disable MFA (Multi-Factor Authentication).
-
enableMfa(
String totp) → Future< void> - Enable MFA (Multi-Factor Authentication).
-
generateMfa(
) → Future< MultiFactorAuthResponse> - Generates an MFA (Multi-Factor Authentication) QR-code.
-
getClaim(
String jwtClaim) → String? -
login(
{required String email, required String password}) → Future< AuthResponse> -
Authenticates a user using an
email
andpassword
. -
logout(
{bool all = false}) → Future< AuthResponse> - Logs out the current user.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
refreshSession(
) → Future< void> -
register(
{required String email, required String password, Map< String, String> ? userData, String? defaultRole, List<String> ? allowedRoles}) → Future<AuthResponse> -
Creates a user from an
email
andpassword
. -
requestEmailChange(
{required String newEmail}) → Future< void> - Requests an email change for the logging in user.
-
requestPasswordChange(
{required String email}) → Future< void> - Requests a password change for a user.
-
setSession(
Session session) → Future< void> -
Updates the Auth to begin identifying as the user described by
session
. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited