FrappeAuthController class

An extension of AuthController containing authentication properties and methods specific to Frappé.

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

Inheritance

Constructors

FrappeAuthController(RenovationConfig config, {FrappeSessionStatusInfo? sessionStatusInfo})
If sessionStatusInfo is not null, the session and the token will be set locally.

Properties

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

Methods

changePassword({required String oldPassword, required String newPassword}) Future<RequestResponse<bool?>>
Changes the password of the currently logged in user.
override
changeUserLanguage(String lang) Future<bool?>
Returns true if the user's language preference in the backend is changed to the language lang.
override
checkLogin({bool? shouldUpdateSession = true}) Future<RequestResponse<FrappeSessionStatusInfo?>>
Checks the session's status (Whether the user is logged in or not) and returns it as FrappeSessionStatusInfo.
override
clearAuthToken() → void
Removes currentToken and removes the Authorization header from RequestOptions
override
clearCache() → void
Clears the current user's roles.
inherited
enableJWT() → void
Enables JWT if the app 'renovation_core' is installed
estimatePassword(String password, {String? firstName, String? lastName, String? middleName, String? email, String? dateOfBirth, List<String>? otherInputs}) 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)
override
generatePasswordResetOTP({RESET_ID_TYPE? idType, String? id, OTP_MEDIUM? medium, String? mediumId}) Future<RequestResponse<GenerateResetOTPResponse?>>
Generates the OTP and sends it through the chosen medium and mediumId.
override
getCore() Renovation
Gets the reference to the Renovation instance
inherited
getCurrentToken() String?
Returns the current JWT token formatted as TOKEN_HEADER token.
override
getCurrentUserRoles() Future<RequestResponse<List<String>>?>
Returns an array of roles assigned to the currently logged in user.
override
getHostUrl() String
Returns the configured host URL towards the backend
inherited
getPasswordResetInfo({RESET_ID_TYPE? type, String? id}) Future<RequestResponse<ResetPasswordInfo?>>
Gets the password possible reset methods & hints about these methods.
override
getSession() FrappeSessionStatusInfo?
Returns the session status from sessionStatus.
inherited
handleError(String? errorId, ErrorDetail? error) → ErrorDetail
Returns the ErrorDetail after manipulating an existing one.
login(String email, [String? password]) Future<RequestResponse<FrappeSessionStatusInfo?>>
Logs in the user (if successful) using email & password. The session (sessionStatus) is updated accordingly.
override
loginViaApple({required String code, required APPLE_OPTION option, String? state}) Future<RequestResponse<FrappeSessionStatusInfo?>>
Logins in using Apple Auth code.
override
loginViaGoogle({required String code, String? state}) Future<RequestResponse<FrappeSessionStatusInfo?>>
Logins in using Google Auth code.
override
logout() Future<RequestResponse>
Logs out the current user.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pinLogin(String user, String pin) Future<RequestResponse<FrappeSessionStatusInfo?>>
Logs in the user (if successful) using user & pin. The session (sessionStatus) is updated accordingly.
override
resetSession() → void
Resets sessionStatus as loggedIn = false with the current timestamp
inherited
sendOTP(String mobileNo, {bool? newOTP = false}) Future<RequestResponse<SendOTPResponse?>>
Sends a request to the backend with the mobile number. The response is a SendOTPResponse.
override
setAuthToken(String? token) → void
Sets the authentication token under currentToken
override
setExternalSession(FrappeSessionStatusInfo? sessionStatusInfo) Future<RequestResponse<FrappeSessionStatusInfo?>>
Sets the session locally obtained externally and validates against the backend.
override
setSession(FrappeSessionStatusInfo? session) → void
Manually update the value of sessionStatus.
inherited
toString() String
A string representation of this object.
inherited
updatePasswordWithToken({String? resetToken, String? newPassword}) Future<RequestResponse<UpdatePasswordResponse?>>
Updates (resets) the password to the chosen password by passing the resetToken.
override
updateSession({FrappeSessionStatusInfo? sessionStatus, bool loggedIn = false, double? useTimestamp}) → void
Updates the session locally.
override
verifyOTP(String mobileNo, String otp, bool loginToUser) Future<RequestResponse<VerifyOTPResponse?>>
Verifies the otp entered by the user against the one sent through sendOTP.
override
verifyPasswordResetOTP({RESET_ID_TYPE? idType, String? id, OTP_MEDIUM? medium, String? mediumId, String? otp}) Future<RequestResponse<VerifyResetOTPResponse?>>
Verifies the otp sent through generatePasswordResetOTP.
override
verifySessionWithBackend(FrappeSessionStatusInfo? info, {bool? shouldUpdateSession = true}) Future<RequestResponse<FrappeSessionStatusInfo?>>
Helper method to verify the local session against Frappé backend.
override

Operators

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

Constants

TOKEN_HEADER → const String
The header to which the token is prepended to according to the requirement of the backend.