DittoAuthenticator
Provides access to authentication information and methods for logging on to
Ditto Cloud. Relevant when using an onlineWithAuthentication
or an
online
identity.
-
Returns the current authentication status.
-
Log in to Ditto with a third-party token.
The completion closure will be called once, whether the login attempt succeeds or fails. If it has failed then the optional
DittoSwiftError
will be non-nil
, otherwise it will benil
. Regardless of whether or not the login attempt succeeds the optionalString
argument will be non-nil
if the auth webhook endpoint returned any JSON value under theclientInfo
key. That JSON string is what will be passed via theString?
argument, if it’s provided.@param token the authentication token required to log in. @param provider the name of the authentication provider. @param completion a closure that will get called when the login attempt has completed.
-
Log in to Ditto with a username and password.
@param username the username component of the credentials used for log in. @param password the password component of the credentials used for log in. @param provider the name of the authentication provider. @param completion a closure that will get called when the login attempt has completed.
-
Log out of Ditto.
This will stop sync, shut down all replication sessions, and remove any cached authentication credentials. Use the optional
cleanup
closure to perform any required cleanup.Note that this does not remove any data from the store. The ditto instance returned in the cleanup closure will no longer be authorized for write transactions, e.g.
remove()
, however, data may be evicted.@param cleanup an optional closure that will be called with the relevant
Ditto
instance as the sole argument that allows you to perform any required cleanup of the store as part of the logout process. -
Registers a block that will be called whenever authentication
status
changes. Returns aDittoObserver
that needs to be retained as long as you want to receive the updates.