AuthenticationRepository

class AuthenticationRepository(authHttpClient: HttpClient, val bridgeConfig: BridgeConfig, val database: ResourceDatabaseHelper, backgroundScope: CoroutineScope, encryptedSharedSettings: EncryptedSharedSettings) : KoinComponent, AuthenticationProvider

Constructors

Link copied to clipboard
constructor(authHttpClient: HttpClient, bridgeConfig: BridgeConfig, database: ResourceDatabaseHelper, backgroundScope: CoroutineScope, encryptedSharedSettings: EncryptedSharedSettings)

Properties

Link copied to clipboard
val appStatus: StateFlow<AppStatus>

A StateFlow with the status of whether or not this version of the app is supported by Bridge. When Bridge services return a http status code of 410, this will emit an AppStatus.UNSUPPORTED.

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard

Get the ID of the current study.

Link copied to clipboard
open fun getKoin(): Koin
Link copied to clipboard

Is the current session authenticated.

Link copied to clipboard

Set the cached UserSessionInfo. This should only be used for migrating apps using old Bridge client libraries. This will do nothing if there already is a session.

Link copied to clipboard
open override fun notifyUIOfBridgeError(statusCode: HttpStatusCode)
Link copied to clipboard
open suspend override fun reAuth(): Boolean
Link copied to clipboard
Link copied to clipboard
suspend fun requestPhoneSignIn(number: String, regionCode: String): ResourceResult<Boolean>

Will send an SMS message with a code that can be used to call the server and generate a session.

Link copied to clipboard
suspend fun resendPhoneVerification(number: String, regionCode: String): ResourceResult<Boolean>

Resend an SMS message to the provided phone number asking the recipient to verify their phone number. Whether the phone has been registered or not through sign up, this method will return 200 in order to prevent \"account enumeration\" security breaches.

Link copied to clipboard
open override fun session(): UserSessionInfo?

Get the current UserSessionInfo object.

Link copied to clipboard

Get the current UserSessionInfo object as a Flow. The flow will emit a new value whenever the session is updated. This allows observers to watch for changes to authentication or consent status.

Link copied to clipboard
suspend fun signInEmail(email: String, password: String): ResourceResult<UserSessionInfo>
Link copied to clipboard
suspend fun signInExternalId(externalId: String, password: String): ResourceResult<UserSessionInfo>
Link copied to clipboard
suspend fun signInPhone(token: String, number: String, regionCode: String): ResourceResult<UserSessionInfo>

Using the token supplied via an SMS message sent to the user, request a session from the server.

Link copied to clipboard
suspend fun signOut()

Calls the sign out api and then clears the local database cache.

Link copied to clipboard
suspend fun signUpEmail(email: String, password: String, testUser: Boolean = false, name: String? = null, sharingScope: SharingScope? = null, dataGroups: List<String>? = null): Boolean