Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5632,6 +5632,10 @@ PrefabInstance:
propertyPath: m_AnchoredPosition.y
value: -30
objectReference: {fileID: 0}
- target: {fileID: 8487389677508608465, guid: 0c02c593eecb0174ebcf32a41af3fec4, type: 3}
propertyPath: m_AnchoredPosition.x
value: -35.2
objectReference: {fileID: 0}
m_RemovedComponents:
- {fileID: 4205968463216469713, guid: 0c02c593eecb0174ebcf32a41af3fec4, type: 3}
m_RemovedGameObjects: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ private async UniTaskVoid AuthenticateAsync(LoginMethod method, CancellationToke
catch (Web3Exception e)
{
loginException = e;
machine.Enter<LoginSelectionAuthState, PopupType>(PopupType.CONNECTION_ERROR);
machine.Enter<LoginSelectionAuthState, ErrorType>(ErrorType.CONNECTION_ERROR);
}
catch (Exception e)
{
loginException = e;
machine.Enter<LoginSelectionAuthState, PopupType>(PopupType.CONNECTION_ERROR);
machine.Enter<LoginSelectionAuthState, ErrorType>(ErrorType.CONNECTION_ERROR);
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,7 @@ public void Enter((string email, CancellationToken ct) payload)
email = payload.email;
loginCt = payload.ct;

view.Show(payload.email);
AuthenticateAsync(payload.email, payload.ct).Forget();

// Listeners
view.BackButton.onClick.AddListener(controller.CancelLoginProcess);
view.ResendCodeButton.onClick.AddListener(ResendOtp);
view.InputField.CodeEntered += OnOTPEntered;
}

public override void Exit()
Expand All @@ -77,6 +71,7 @@ public override void Exit()
SignatureExpiredException ex => new SpanErrorInfo("Web3 signature expired during authentication", ex),
Web3SignatureException ex => new SpanErrorInfo("Web3 signature validation failed", ex),
CodeVerificationException ex => new SpanErrorInfo("Code verification failed during authentication", ex),
InvalidEmailException ex => new SpanErrorInfo("Invalid email provided during authentication", ex),
Exception ex => new SpanErrorInfo("Unexpected error during authentication flow", ex),
};

Expand All @@ -100,6 +95,8 @@ private async UniTaskVoid AuthenticateAsync(string email, CancellationToken ct)
{
controller.CurrentRequestID = string.Empty;

compositeWeb3Provider.OTPSendSuccess += OnOTPSendSuccess;

// awaits OTP code being entered
IWeb3Identity identity = await compositeWeb3Provider.LoginAsync(LoginPayload.ForOtpFlow(email), ct);
machine.Enter<ProfileFetchingAuthState, ProfileFetchingPayload>(new (email, identity, false, ct));
Expand All @@ -124,11 +121,27 @@ private async UniTaskVoid AuthenticateAsync(string email, CancellationToken ct)
loginException = e;
machine.Enter<LoginSelectionAuthState, int>(SLIDE);
}
catch (InvalidEmailException e)
{
loginException = e;
machine.Enter<LoginSelectionAuthState, ErrorType>(ErrorType.INVALID_EMAIL);
}
catch (Exception e)
{
loginException = e;
machine.Enter<LoginSelectionAuthState, PopupType>(PopupType.CONNECTION_ERROR);
machine.Enter<LoginSelectionAuthState, ErrorType>(ErrorType.CONNECTION_ERROR);
}
finally{ compositeWeb3Provider.OTPSendSuccess -= OnOTPSendSuccess; }
}

private void OnOTPSendSuccess(string emailAddress)
{
view.Show(emailAddress);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect

// Hide non-interactable Login Screen
viewInstance.LoginSelectionAuthView.Hide();

to be also here, so we see all switching logic in one place and understand how transition happens


// Listeners
view.BackButton.onClick.AddListener(controller.CancelLoginProcess);
view.ResendCodeButton.onClick.AddListener(ResendOtp);
view.InputField.CodeEntered += OnOTPEntered;
}

private void OnOTPEntered(string otp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ async UniTaskVoid PublishNewProfileAsync(CancellationToken ct)
spanErrorInfo = new SpanErrorInfo("Exception on finalizing new user", e);

view.Hide(UIAnimationHashes.SLIDE);
fsm.Enter<LoginSelectionAuthState, PopupType>(PopupType.CONNECTION_ERROR);
fsm.Enter<LoginSelectionAuthState, ErrorType>(ErrorType.CONNECTION_ERROR);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace DCL.AuthenticationScreenFlow
{
public class LoginSelectionAuthState : AuthStateBase, IState, IPayloadedState<PopupType>, IPayloadedState<int>
public class LoginSelectionAuthState : AuthStateBase, IState, IPayloadedState<ErrorType>, IPayloadedState<int>
{
private const string REQUEST_BETA_ACCESS_LINK = "https://68zbqa0m12c.typeform.com/to/y9fZeNWm";

Expand Down Expand Up @@ -40,6 +40,8 @@ public LoginSelectionAuthState(MVCStateMachine<AuthStateBase> machine,
this.webBrowser = webBrowser;
this.enableEmailOTP = enableEmailOTP;

compositeWeb3Provider.OTPSendSuccess += OnOTPSendSuccess;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove this subscription and move related login inside IdentityAndVerification state similarly as it done in same state for dApp flow - when Verification required this state handles both views there like this:

// Hide non-interactable Login Screen
viewInstance.LoginSelectionAuthView.Hide();

// Show Verification Screen
view.Show(data.code, data.expiration);
view.BackButton.onClick.AddListener(controller.CancelLoginProcess);

so you will re-use same viewInstance.LoginSelectionAuthView.Hide();


// Cancel button persists in the Verification state (until code is shown)
view.CancelLoginButton.onClick.AddListener(OnCancelBeforeVerification);
}
Expand All @@ -50,6 +52,7 @@ public LoginSelectionAuthState(MVCStateMachine<AuthStateBase> machine,
currentState.Value = AuthStatus.LoginSelectionScreen;

view.SetLoadingSpinnerVisibility(false);
view.SetEmailInputFieldSpinnerActive(false);

if (view.gameObject.activeSelf)
{
Expand Down Expand Up @@ -109,18 +112,22 @@ public override void Exit()
base.Exit();
}

public void Enter(PopupType popupType)
public void Enter(ErrorType errorType)
{
switch (popupType)
switch (errorType)
{
case PopupType.NONE: break;
case PopupType.CONNECTION_ERROR:
case ErrorType.NONE: break;
case ErrorType.CONNECTION_ERROR:
view.ErrorPopupRoot.SetActive(true);
break;
case PopupType.RESTRICTED_USER:
case ErrorType.RESTRICTED_USER:
view.RestrictedUserContainer.SetActive(true);
break;
default: throw new ArgumentOutOfRangeException(nameof(popupType), popupType, null);
case ErrorType.INVALID_EMAIL:
view.SetEmailInputFieldErrorState(true);
Enter();
return;
default: throw new ArgumentOutOfRangeException(nameof(errorType), errorType, null);
}

Enter(UIAnimationHashes.SLIDE);
Expand Down Expand Up @@ -178,10 +185,16 @@ private void OTPLogin()

controller.CurrentLoginMethod = LoginMethod.EMAIL_OTP;
currentState.Value = AuthStatus.LoginRequested;
view.SetEmailInputFieldSpinnerActive(true);

view.Hide();
machine.Enter<IdentityVerificationOTPAuthState, (string, CancellationToken)>(
payload: (viewInstance.LoginSelectionAuthView.EmailInputField.Text, controller.GetRestartedLoginToken()));
payload: (view.EmailInputField.Text, controller.GetRestartedLoginToken()));
}

private void OnOTPSendSuccess(string _)
{
view.SetEmailInputFieldSpinnerActive(false);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this inside the view logic (inside its Hide)

view.Hide();
}

private void OnRetryFromError()
Expand All @@ -203,10 +216,11 @@ private void RequestAlphaAccess() =>
webBrowser.OpenUrl(REQUEST_BETA_ACCESS_LINK);
}

public enum PopupType
public enum ErrorType
{
NONE = 0,
CONNECTION_ERROR = 1,
RESTRICTED_USER = 2,
INVALID_EMAIL = 3,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private async UniTaskVoid FetchProfileFlowAsync(string email, IWeb3Identity iden
if (!IsUserAllowedToAccessToBeta(identity))
{
profileFetchException = new NotAllowedUserException($"User not allowed to access beta - restricted user {email} in {nameof(ProfileFetchingAuthState)} ({(isCached ? "cached" : "main")} flow)");
machine.Enter<LoginSelectionAuthState, PopupType>(PopupType.RESTRICTED_USER);
machine.Enter<LoginSelectionAuthState, ErrorType>(ErrorType.RESTRICTED_USER);
}
else
{
Expand Down Expand Up @@ -134,7 +134,7 @@ private async UniTaskVoid FetchProfileFlowAsync(string email, IWeb3Identity iden
catch (Exception e)
{
profileFetchException = e;
machine.Enter<LoginSelectionAuthState, PopupType>(PopupType.CONNECTION_ERROR);
machine.Enter<LoginSelectionAuthState, ErrorType>(ErrorType.CONNECTION_ERROR);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ public void SetLoadingSpinnerVisibility(bool isLoading)
loadingSpinner.SetActive(isLoading);
}

public void SetEmailInputFieldSpinnerActive(bool isActive) =>
EmailInputField.SetSpinnerActive(isActive);

public void SetEmailInputFieldErrorState(bool hasError) =>
EmailInputField.SetErrorState(hasError);

public override async UniTask ShowAsync(CancellationToken ct)
{
await base.ShowAsync(ct);
Expand Down
124 changes: 124 additions & 0 deletions Explorer/Assets/DCL/UI/Assets/TextInput.Email.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,10 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier: UI::EmailInputView
inputField: {fileID: 3915402350510907255}
autoFocus: 0
startButton: {fileID: 4126780924162471401}
errorContainer: {fileID: 3988503103806457292}
loadingSpinner: {fileID: 5013519038683381383}
outline: {fileID: 4418198438385915273}
outlineNormalColor: {r: 1, g: 1, b: 1, a: 1}
outlineErrorColor: {r: 1, g: 0, b: 0, a: 1}
Expand Down Expand Up @@ -800,6 +802,125 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &7347865896262875150
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 7945084868567568428}
m_Modifications:
- target: {fileID: 1166888513132788191, guid: d565b61885fb1ef41b1582a285e748e9, type: 3}
propertyPath: m_Pivot.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 1166888513132788191, guid: d565b61885fb1ef41b1582a285e748e9, type: 3}
propertyPath: m_Pivot.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1166888513132788191, guid: d565b61885fb1ef41b1582a285e748e9, type: 3}
propertyPath: m_AnchorMax.x
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1166888513132788191, guid: d565b61885fb1ef41b1582a285e748e9, type: 3}
propertyPath: m_AnchorMax.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 1166888513132788191, guid: d565b61885fb1ef41b1582a285e748e9, type: 3}
propertyPath: m_AnchorMin.x
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1166888513132788191, guid: d565b61885fb1ef41b1582a285e748e9, type: 3}
propertyPath: m_AnchorMin.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 1166888513132788191, guid: d565b61885fb1ef41b1582a285e748e9, type: 3}
propertyPath: m_SizeDelta.x
value: 24
objectReference: {fileID: 0}
- target: {fileID: 1166888513132788191, guid: d565b61885fb1ef41b1582a285e748e9, type: 3}
propertyPath: m_SizeDelta.y
value: 24
objectReference: {fileID: 0}
- target: {fileID: 1166888513132788191, guid: d565b61885fb1ef41b1582a285e748e9, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1166888513132788191, guid: d565b61885fb1ef41b1582a285e748e9, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1166888513132788191, guid: d565b61885fb1ef41b1582a285e748e9, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1166888513132788191, guid: d565b61885fb1ef41b1582a285e748e9, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1166888513132788191, guid: d565b61885fb1ef41b1582a285e748e9, type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 1166888513132788191, guid: d565b61885fb1ef41b1582a285e748e9, type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 1166888513132788191, guid: d565b61885fb1ef41b1582a285e748e9, type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 1166888513132788191, guid: d565b61885fb1ef41b1582a285e748e9, type: 3}
propertyPath: m_AnchoredPosition.x
value: -41.6
objectReference: {fileID: 0}
- target: {fileID: 1166888513132788191, guid: d565b61885fb1ef41b1582a285e748e9, type: 3}
propertyPath: m_AnchoredPosition.y
value: 12
objectReference: {fileID: 0}
- target: {fileID: 1166888513132788191, guid: d565b61885fb1ef41b1582a285e748e9, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1166888513132788191, guid: d565b61885fb1ef41b1582a285e748e9, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1166888513132788191, guid: d565b61885fb1ef41b1582a285e748e9, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: -336.96002
objectReference: {fileID: 0}
- target: {fileID: 2336035712942851721, guid: d565b61885fb1ef41b1582a285e748e9, type: 3}
propertyPath: m_Name
value: LoadingSpinner
objectReference: {fileID: 0}
- target: {fileID: 2336035712942851721, guid: d565b61885fb1ef41b1582a285e748e9, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3817016671180041992, guid: d565b61885fb1ef41b1582a285e748e9, type: 3}
propertyPath: m_Maskable
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3849787312596893835, guid: d565b61885fb1ef41b1582a285e748e9, type: 3}
propertyPath: m_Maskable
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: d565b61885fb1ef41b1582a285e748e9, type: 3}
--- !u!1 &5013519038683381383 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 2336035712942851721, guid: d565b61885fb1ef41b1582a285e748e9, type: 3}
m_PrefabInstance: {fileID: 7347865896262875150}
m_PrefabAsset: {fileID: 0}
--- !u!224 &8487389677508608465 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 1166888513132788191, guid: d565b61885fb1ef41b1582a285e748e9, type: 3}
m_PrefabInstance: {fileID: 7347865896262875150}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &7826701639465835861
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -962,6 +1083,9 @@ PrefabInstance:
- targetCorrespondingSourceObject: {fileID: 206210363645562233, guid: 593328dae0676544bbbac027ee30f9d5, type: 3}
insertIndex: -1
addedObject: {fileID: 3968719757611060151}
- targetCorrespondingSourceObject: {fileID: 206210363645562233, guid: 593328dae0676544bbbac027ee30f9d5, type: 3}
insertIndex: -1
addedObject: {fileID: 8487389677508608465}
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 593328dae0676544bbbac027ee30f9d5, type: 3}
--- !u!114 &3915402350510907255 stripped
Expand Down
Loading
Loading