TKMUserManager
public protocol TKMUserManager
The user manager takes care of user authentication and provides access to the currently logged-in users.
The following code sample illustrates how to use this class to retrieve the list of logged-in users.
let userManager = tapkeyServiceFactory.userManager
let users = userManager.users
// Now, users contains a list of IDs of all logged-in users. Usually, users.count will be 1,
// however, it is possible to log in multiple users at the same time.
The exemplary code below demonstrates how to log in a user:
let userManager = tapkeyServiceFactory.userManager
userManager.logInAsync(accessToken: tapkeyAccessToken, cancellationToken: ct)
Implementors have to make sure that a token refresh handler was set via the TKMServiceFactory builder prior to logging in any users.
-
Returns IDs of the users who are currently logged in.
Declaration
Swift
var users: [String] { get }
-
Logs in a user with a Tapkey access token.
Declaration
Swift
func logInAsync(accessToken: String, cancellationToken: TKMCancellationToken) -> TKMPromise<String>
Parameters
accessToken
the Tapkey access token to be used for logging in the user.
cancellationToken
can be used to get notified on cancel events.
Return Value
a Promise that resolves to the ID of the user logged in.
-
Logs out a user with a Tapkey access token.
Declaration
Swift
func logOutAsync(userId: String, cancellationToken: TKMCancellationToken) -> TKMPromise<Void>
Parameters
userId
the ID of the user to be logged out.
cancellationToken
can be used to get notified on cancel events.
Return Value
a Promise that resolves after the logout has completed.
-
Replaces the access token for the specified user.
Declaration
Swift
func updateAccessToken(userId: String, accessToken: String)
Parameters
userId
the ID of the user whose access token is to be replaced.
accessToken
the new access token