AuthController<K extends SessionStatusInfo?> class abstract

A controller containing authentication properties and methods.

Authentication methods include standard email/pwd login, OTP login, updating session, etc..

Inheritance
Implementers

Constructors

AuthController(RenovationConfig config, {K? sessionStatusInfo})
Listen to changes in sessionStatus and log them in console

Properties

config RenovationConfig
finalinherited
currentToken String?
The token (JWT) of the current session.
getter/setter pair
currentUser String?
The current signed in user (if any).
getter/setter pair
currentUserRoles List<String>?
The current signed in user's roles.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
isLoggedIn bool
Returns a boolean whether the current user is logged in.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sessionStatus ↔ BehaviorSubject<K?>
getter/setter pair

Methods

changePassword({required String oldPassword, required String newPassword}) Future<RequestResponse<bool?>>
Changes the password of the currently logged in user.
changeUserLanguage(String lang) Future<bool?>
Changes the user's language preference in the backend to the language lang.
checkLogin({bool? shouldUpdateSession}) Future<RequestResponse<K>>
Checks the session's status (Whether the user is logged in or not) and returns it as SessionStatusInfo
clearAuthToken() → void
Removes the authentication token where relevant.
clearCache() → void
Clears the current user's roles.
override
estimatePassword(String password) Result
Check the password's strength result.score : Integer from 0-4 (useful for implementing a strength bar) 0 # too guessable: risky password. (guesses < 10^3) 1 # very guessable: protection from throttled online attacks. (guesses < 10^6) 2 # somewhat guessable: protection from unthrottled online attacks. (guesses < 10^8) 3 # safely unguessable: moderate protection from offline slow-hash scenario. (guesses < 10^10) 4 # very unguessable: strong protection from offline slow-hash scenario. (guesses >= 10^10)
generatePasswordResetOTP() Future<RequestResponse>
Generates the OTP and sends it through the chosen medium.
getCore() Renovation
Gets the reference to the Renovation instance
inherited
getCurrentToken() String?
Returns the current JWT token formatted as TOKEN_HEADER token.
getCurrentUserRoles() Future<RequestResponse<List<String>>?>
Returns an array of roles assigned to the currently logged in user.
getHostUrl() String
Returns the configured host URL towards the backend
inherited
getPasswordResetInfo() Future<RequestResponse>
Gets the password possible reset methods & hints about these methods
getSession() → K?
Returns the session status from sessionStatus.
handleError(String errorId, ErrorDetail error) → ErrorDetail
Returns the ErrorDetail after manipulating an existing one.
inherited
login(String email, [String? password]) Future<RequestResponse<K>>
Logs in the user (if successful) using email & password.
loginViaApple({required String code, required APPLE_OPTION option, String? state}) Future<RequestResponse<K>>
Logins in using Apple Auth code.
loginViaGoogle({required String code, String? state}) Future<RequestResponse<K>>
Logins in using Google Auth code.
logout() Future<RequestResponse>
Logs out the current user.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pinLogin(String user, String pin) Future<RequestResponse<K>>
Logs in the user (if successful) using user & pin.
resetSession() → void
Resets sessionStatus as loggedIn = false with the current timestamp
sendOTP(String mobileNo, {bool? newOTP}) Future<RequestResponse<SendOTPResponse?>>
Sends a request to the backend with the mobile number. The response is a SendOTPResponse.
setAuthToken(String token) → void
Sets the token (JWT).
setExternalSession(K sessionStatusInfo) Future<RequestResponse<K>>
Sets the session locally obtained externally.
setSession(K session) → void
Manually update the value of sessionStatus.
toString() String
A string representation of this object.
inherited
updatePasswordWithToken() Future<RequestResponse>
Updates (resets) the password to the chosen password.
updateSession({K? sessionStatus, bool loggedIn = false, double? useTimestamp}) → void
Updates the sessionStatus.
verifyOTP(String mobileNo, String otp, bool loginToUser) Future<RequestResponse<VerifyOTPResponse?>>
Verifies the otp entered by the user against the one sent through sendOTP.
verifyPasswordResetOTP() Future<RequestResponse>
Verifies the OTP sent through generatePasswordResetOTP.
verifySessionWithBackend(K info, {bool shouldUpdateSession = true}) Future<RequestResponse<K>>
Helper method to verify the local session against the backend.

Operators

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