MimiAuthController
public protocol MimiAuthController : MimiCoreController
Controller which provides access to Mimi account authentication.
MimiAuthController
is the focal point for all authentication related logic,
providing access to the current authentication status, and the functions required
for modifying the auth status. All authentication context should be provided from here.
-
Observable for the auth controller.
Declaration
Swift
var observable: MimiCoreObservable<MimiAuthControllerObservable> { get }
-
The currently authenticated user.
Declaration
Swift
var currentUser: MimiUser? { get }
-
Authenticate a user.
Warning
When using the
deviceAuthorization
route
you should always handle theMimiAuthTokenRequest
object that is returned from this function. AsdeviceAuthorization
will continuously poll for authentication until expiry, you are responsible for cancelling the request if it is no longer required.Declaration
Swift
@discardableResult func authenticate(route: MimiAuthRoute, result: MimiCoreResultHandler<MimiUser>) -> MimiAuthTokenRequest?
Parameters
route
The route of authentication to use.
result
Result of the authentication request.
Return Value
Request for the token that can be cancelled (only available when polling required).
-
Reset the password of a user.
- email: The email of the user
Declaration
Swift
func resetPassword(email: String, result: MimiCoreResultHandler<Void>)
-
Request remote authorization for the current device.
Declaration
Swift
func requestDeviceAuthorization(result: MimiCoreResultHandler<MimiDeviceAuthRequest>)
Parameters
result
Result of the request.
-
Approve an authorization request for a remote device.
Declaration
Swift
func approveDeviceAuthorization(request: MimiDeviceAuthRequest, result: MimiCoreResultHandler<Void>)
Parameters
request
Authorization request to approve.
result
Result of the approval request.
-
Log out the current user.
Declaration
Swift
func logOut()
-
Reload the current user.
Declaration
Swift
func reloadUser(result: MimiCoreResultHandler<MimiUser>)
Parameters
result
Result of the user reload.
-
Asynchronously loads the URL of the user account portal.
This function retrieves the URL for the user account portal, allowing users to access their account information.
Throws
An error if the loading process encounters any issues.Declaration
Swift
func loadUserAccountPortalURL() async throws -> URL
Return Value
An asynchronous task that returns a
URL
representing the user account portal URL.