AuthController class

Central auth controller. Handles both AuthMethod.phone and AuthMethod.email.

Delegates each domain to a focused mixin:

  • Phone OTP flow → _PhoneAuthMixin
  • Email + password → _EmailAuthMixin
  • Password reset / change → _PasswordMixin
  • Session management → _SessionMixin
  • Invite acceptance → _InviteMixin

Inject via: ref.watch(authControllerProvider) State: AuthState

Annotations
  • @Riverpod.new(keepAlive: true)

Constructors

AuthController()

Properties

dio → Dio
The authenticated Dio instance. Available synchronously after build. Consumed by dioProvider.
no setter
hashCode int
The hash code for this object.
no setterinherited
ref → Ref
The Ref associated with this notifier.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
state AuthState
The value currently exposed by this notifier.
getter/setter pairinherited
stateOrNull AuthState?
The value currently exposed by this Notifier.
no setterinherited

Methods

build() AuthState
changePassword({required String currentPassword, required String newPassword}) Future<bool>
inherited
clearError() → void
Clears any existing error from the state.
forgotPassword(String email) Future<bool>
inherited
getSessions() Future<List<AuthSession>>
Returns all active sessions for the current user.
inherited
listenSelf(void listener(AuthState? previous, AuthState next), {void onError(Object error, StackTrace stackTrace)?}) → RemoveListener
Listens to changes on the value exposed by this provider.
inherited
loginWithEmail({required String email, required String password}) Future<bool>
inherited
loginWithToken(String phoneGrantToken) Future<bool>
Step 3a: Login an existing user using the temp token from verifyOtp.
inherited
logout() Future<void>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerWithEmail(EmailRegisterRequest request) Future<bool>
inherited
registerWithPhone(PhoneRegisterRequest request) Future<bool>
Step 3b: Register a new user via the phone OTP flow.
inherited
resendOtp(String sessionToken) Future<OtpData?>
Step 2b: Resend OTP to the same session.
inherited
resetPassword({required String token, required String newPassword}) Future<bool>
inherited
resetPasswordViaPhone({required String phoneGrantToken, required String newPassword}) Future<bool>
inherited
revokeSession(String sessionId) Future<bool>
Revokes a specific session by ID.
inherited
runBuild() → void
Executes Notifier.build.
inherited
sendOtp(String phone) Future<OtpData?>
Step 1: Send OTP to the given phone number.
inherited
toString() String
A string representation of this object.
inherited
updateShouldNotify(AuthState previous, AuthState next) bool
A method invoked when the state exposed by this Notifier changes. It compares the previous and new value, and return whether listeners should be notified.
inherited
verifyOtp({required String verificationId, required String otp}) Future<PhoneLookupResult?>
Step 2: Verify OTP code. Returns a PhoneLookupResult indicating whether this is a login (existing user) or registration (new user).
inherited

Operators

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