IProjectVAuthenticationPresenter interface
The sign-in contract for the Login scene: observe the state, call a command, redraw on change. Commands return a result for server, network and input failures instead of throwing. A command started while another runs waits for it to finish.
Namespace: SilverTiger.ProjectV.Unity.Presentation.Authentication
public interface IProjectVAuthenticationPresenter
Properties
| Property | Type | Description |
|---|---|---|
Current | ProjectVAuthenticationSnapshot | The sign-in state right now; never null. Starts as SignedOut. |
Methods
GetNativeAvailability(ProjectVNativeAuthenticationProvider provider)
Tells whether a Google or Apple sign-in button can work on this device and build.
ProjectVNativeAuthenticationAvailabilityView GetNativeAvailability(ProjectVNativeAuthenticationProvider provider);
Parameters
| Name | Type | Description |
|---|---|---|
provider | ProjectVNativeAuthenticationProvider | The sign-in provider to check. |
Returns
ProjectVNativeAuthenticationAvailabilityView: The availability; show the button only when ProjectVNativeAuthenticationAvailabilityView.IsAvailable is true.
Exceptions
| Exception | When |
|---|---|
ArgumentOutOfRangeException | provider is not a known provider. |
SubscribeAsync(Action<ProjectVAuthenticationSnapshot> listener)
Calls listener with the current state right away, then again on every change.
Task<IDisposable> SubscribeAsync(Action<ProjectVAuthenticationSnapshot> listener);
Parameters
| Name | Type | Description |
|---|---|---|
listener | Action<ProjectVAuthenticationSnapshot> | Redraws the Login UI; must not be null. An exception it throws on a later change is ignored. |
Returns
Task<IDisposable>: The subscription; dispose it when the scene closes.
Exceptions
| Exception | When |
|---|---|
ArgumentNullException | listener is null. |
ObjectDisposedException | The presenter was already shut down. |
RestoreAsync(CancellationToken cancellationToken)
Signs the player back in with the sign-in saved from an earlier play, if there is one. Call it when the Login scene opens.
Task<ProjectVAuthenticationCommandResult> RestoreAsync(CancellationToken cancellationToken);
Parameters
| Name | Type | Description |
|---|---|---|
cancellationToken | CancellationToken | Cancels the attempt, for example when the scene closes. |
Returns
Task<ProjectVAuthenticationCommandResult>: When a saved sign-in worked, ProjectVAuthenticationSnapshot.IsAuthenticated is true. When there was none, ProjectVAuthenticationCommandResult.IsSuccess is true and the state is SignedOut: show the sign-in options. When the saved sign-in was refused, the state is SignedOut with an ProjectVAuthenticationSnapshot.Error; show the sign-in options too.
LoginPasswordAsync(string username, string password, CancellationToken cancellationToken)
Signs in with a username and password.
Task<ProjectVAuthenticationCommandResult> LoginPasswordAsync(string username, string password, CancellationToken cancellationToken);
Parameters
| Name | Type | Description |
|---|---|---|
username | string | The username the player typed; a blank value fails without contacting the server. |
password | string | The password the player typed; an empty value fails without contacting the server. |
cancellationToken | CancellationToken | Cancels the attempt. |
Returns
Task<ProjectVAuthenticationCommandResult>: ProjectVAuthenticationSnapshot.IsAuthenticated is true when the player is signed in. Otherwise ProjectVAuthenticationSnapshot.Error says why, for example refused credentials.
RegisterPasswordAsync(ProjectVPasswordRegistrationInput input, CancellationToken cancellationToken)
Creates a username and password account. It does not sign the player in: on success, call LoginPasswordAsync with the same username and password.
Task<ProjectVAuthenticationCommandResult> RegisterPasswordAsync(ProjectVPasswordRegistrationInput input, CancellationToken cancellationToken);
Parameters
| Name | Type | Description |
|---|---|---|
input | ProjectVPasswordRegistrationInput | What the player typed into the register form; a blank username or empty password fails without contacting the server. |
cancellationToken | CancellationToken | Cancels the attempt. |
Returns
Task<ProjectVAuthenticationCommandResult>: ProjectVAuthenticationCommandResult.IsSuccess is true when the account was created; the state is then SignedOut. Otherwise ProjectVAuthenticationSnapshot.Error says why, for example the username is taken.
Exceptions
| Exception | When |
|---|---|
ArgumentNullException | input is null. |
SignInWithGoogleAsync(ProjectVNativeAuthenticationOptions? options, CancellationToken cancellationToken)
Opens the Google sign-in prompt, then signs the player in with the chosen Google account.
Task<ProjectVAuthenticationCommandResult> SignInWithGoogleAsync(ProjectVNativeAuthenticationOptions? options, CancellationToken cancellationToken);
Parameters
| Name | Type | Description |
|---|---|---|
options | ProjectVNativeAuthenticationOptions? | Extra options, or null. |
cancellationToken | CancellationToken | Cancels the attempt. |
Returns
Task<ProjectVAuthenticationCommandResult>: ProjectVAuthenticationSnapshot.IsAuthenticated is true when the player is signed in. Otherwise ProjectVAuthenticationSnapshot.Error says why: the Cancelled category means the player closed the prompt. It also fails when Google sign-in is not available on this device.
SignInWithAppleAsync(ProjectVNativeAuthenticationOptions? options, CancellationToken cancellationToken)
Opens the Sign in with Apple prompt, then signs the player in with the chosen Apple ID.
Task<ProjectVAuthenticationCommandResult> SignInWithAppleAsync(ProjectVNativeAuthenticationOptions? options, CancellationToken cancellationToken);
Parameters
| Name | Type | Description |
|---|---|---|
options | ProjectVNativeAuthenticationOptions? | Extra options, or null. |
cancellationToken | CancellationToken | Cancels the attempt. |
Returns
Task<ProjectVAuthenticationCommandResult>: ProjectVAuthenticationSnapshot.IsAuthenticated is true when the player is signed in. Otherwise ProjectVAuthenticationSnapshot.Error says why: the Cancelled category means the player closed the prompt. It also fails when Apple sign-in is not available on this device.
AuthenticateDeviceAsync(string id, ProjectVNativeAuthenticationOptions? options, CancellationToken cancellationToken)
Signs in as a Guest tied to this device. Get the ID from IProjectVGuestIdentityProvider.GetOrCreateAsync so the player keeps the same Guest account.
Task<ProjectVAuthenticationCommandResult> AuthenticateDeviceAsync(string id, ProjectVNativeAuthenticationOptions? options, CancellationToken cancellationToken);
Parameters
| Name | Type | Description |
|---|---|---|
id | string | The device's Guest ID; a blank value fails without contacting the server. |
options | ProjectVNativeAuthenticationOptions? | Extra options, or null. |
cancellationToken | CancellationToken | Cancels the attempt. |
Returns
Task<ProjectVAuthenticationCommandResult>: ProjectVAuthenticationSnapshot.IsAuthenticated is true when the player is signed in. Otherwise ProjectVAuthenticationSnapshot.Error says why.