CodelesslyAuthManager class

An implementation of that uses Firebase auth.

Inheritance

Constructors

CodelesslyAuthManager({required CodelesslyConfig config, required CacheManager cacheManager, required FirebaseAuth firebaseAuth, required CodelesslyErrorHandler errorHandler, AuthData? authData})
Creates a CodelesslyAuthManager instance.

Properties

authData AuthData?
Returns the auth data used to authenticate the token if it exists.
no setteroverride
authStream Stream<AuthData?>
Returns the stream of the auth data. Any changes to it will be broadcast to the stream.
no setteroverride
cacheManager CacheManager
The cache manager used to store the auth data after authentication.
final
config CodelesslyConfig
The configuration used to authenticate the token.
final
errorHandler → CodelesslyErrorHandler
The error handler used to report errors.
final
firebaseAuth → FirebaseAuth
The firebase auth instance used to authenticate the device anonymously.
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

authenticate() Future<void>
Calls a cloud function with the auth token as a payload. The cloud function will validate the token and return a project id. The project id will be used to retrieve the layout from the database.
override
checkClaimsForProject(IdTokenResult? result, String projectId) bool
A helper method to check if the user has access to a project given their result from getIdTokenResult and the projectId they're trying to access.
dispose() → void
Disposes this instance of the AuthManager.
override
getBestPublishSource(CodelesslyConfig config) PublishSource
Returns the PublishSource to be used for fetching the published model. If the AuthData reveals that the project is a template, then the PublishSource.template is returned, otherwise the PublishSource configured in the CodelesslyConfig is returned.
inherited
hasCloudStorageAccess(String projectId) bool
Returns true if the user has access to cloud storage.
override
init() Future<void>
Initializes the AuthManager.
override
isAuthenticated() bool
Returns true if a handshake was done successfully.
override
log(String message, {bool largePrint = false}) → void
A helper function to log messages.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
postAuthSuccess(AuthData authData) Future<void>
This method is called after successful authentication of the token. It checks if the user has access to the project via token claims and if not, it listens to Firebase Auth user changes until the claim appears on the user's token and then completes the Firebase Auth process.
reset() → void
Sets the AuthData to null and emits a null value to the stream.
override
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

verifyProjectAuthToken({required String userToken, required CodelesslyConfig config, required Future<void> postSuccess(AuthData authData)}) Future<AuthData?>
Verifies the project auth token by making a POST request to the Codelessly's backend.