AuthenticationState
@frozen
public enum AuthenticationState : Codable, Equatable, CustomStringConvertible, CustomDebugStringConvertible
A value representing an authentication state.
After using the AuthenticationService.unauthenticate(queue:then:)
method,
the authentication always goes into the AuthenticationState.unauthenticated
state.
After a successful authentication, the authentication always goes into the AuthenticationState.authenticated(details:)
state.
After a failed authentication, the authentication state never changes.
In particular, the AuthenticationState.authenticated(details:)
state is preserved since the previous authentication is always valid.
When the connection to the back-end is lost, the authentication state is frozen, unless the AuthenticationService.unauthenticate(queue:then:)
method is used.
-
Indicates that there is a valid authentication token.
The associated value contains information about the authenticated user.
From this state:
- the
AuthenticationService.unauthenticate(queue:then:)
method brings to the.unauthenticated
state, - the expiration of the token or a reject of the token by the back-end when going back online brings to the
.invalid
state.
Declaration
Swift
case authenticated(details: AuthenticationDetails)
- the
-
Indicates that the current authentication token is no longer valid.
This state is obtained in two cases:
- when the authentication token has expired,
- when the authentication token is rejected by the back-end when going back online.
From this state:
- a successful authentication brings to the
.authenticated(details:)
state, - the
AuthenticationService.unauthenticate(queue:then:)
method brings to the.unauthenticated
state.
Declaration
Swift
case invalid
-
Indicates that there is currently no authentication token.
From this state, a successful authentication brings to the
.authenticated(details:)
state.Declaration
Swift
case unauthenticated
-
Declaration
Swift
public init(from decoder: Decoder) throws
-
Declaration
Swift
public func encode(to encoder: Encoder) throws
-
The details of the user currently authenticated.
This property is
nil
when there is currently no valid authentication token. i.e. when this value does not match the.authenticated(details:)
case.Declaration
Swift
public var details: AuthenticationDetails? { get }
-
Declaration
Swift
public var description: String { get }
-
Declaration
Swift
public var debugDescription: String { get }