AuthService class

Authentication service for handling OTP-based login, logout, and token management

Constructors

AuthService(ApiClient _apiClient)

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

checkUser({required String email}) Future<Map<String, dynamic>>
Check user before OTP request
checkVerificationStatus({required String email}) Future<Map<String, dynamic>>
Check verification status
getCachedUser() Future<UserData?>
Get cached user data
getCurrentTenantId() String?
Get the current tenant ID
getCurrentUser() Future<UserData>
Get current user (me endpoint)
getTokenExpiresAt() Future<String?>
Get stored token expiration time
initialize() Future<void>
Initialize the service
isAuthenticated() Future<bool>
Check if user is authenticated
isTokenExpired({Duration buffer = const Duration(minutes: 1)}) Future<bool>
Check if the current token is expired or will expire soon Returns true if token is expired or will expire within the next minute
logout({bool allDevices = false}) Future<void>
Logout and clear stored data
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
refreshToken() Future<SessionData>
Refresh authentication token
registerTenant({required String email, required String tenantName, required String firstName, required String lastName, String? companyName}) Future<Map<String, dynamic>>
Register new tenant with user
requestOTP({required String email, String? tenantId}) Future<OTPResponse>
Request OTP for email login
resendOTP({required String email}) Future<OTPResponse>
Resend OTP for email
sendVerificationEmail({required String email}) Future<Map<String, dynamic>>
Send verification email
setCurrentTenantId(String tenantId) Future<void>
Set the current tenant ID
toString() String
A string representation of this object.
inherited
verifyEmail({required String token}) Future<Map<String, dynamic>>
Verify email with token
verifyOTP({required String email, required String code, String? tenantId}) Future<LoginOTPResponse>
Verify OTP and login

Operators

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