Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle already used phone in UI #866

Open
wants to merge 2 commits into
base: throw-error-when-exisitng-user-uses-otp
Choose a base branch
from

Conversation

musidlo
Copy link

@musidlo musidlo commented Nov 15, 2024

Copy link

Playwright Report

Summary

Expected Skipped Unexpected Flaky Duration
29 0 54 7 133.97s

Suites

account-rewards.onboarded.spec.ts

can visit rewards page

  • chromium: ❌
  • firefox: ❌

account-sendtag-checkout.onboarded.spec.ts

can visit checkout page

  • chromium: ❌
  • firefox: ❌

can add a pending tag

  • chromium: ❌
  • firefox: ❌

cannot add an invalid tag name

  • chromium: ❌
  • firefox: ❌

can confirm a tag

  • chromium: ❌
  • firefox: ❌

can refer a tag

  • chromium: ❌
  • firefox: ❌

can refer multiple tags in separate transactions

  • chromium: ❌
  • firefox: ❌

cannot confirm a tag without paying

  • chromium: ❌
  • firefox: ❌

cannot add more than 5 tags

  • chromium: ❌
  • firefox: ❌

account-settings-backup.onboarded.spec.ts

can backup account

  • chromium: ❌
  • firefox: ❌

can remove a signer

  • chromium: ❌
  • firefox: ❌

account.logged-in.spec.ts

can visit account page

  • chromium: ❌
  • firefox: ❌

can update profile

  • chromium: ❌
  • firefox: ❌

activity.onboarded.spec.ts

can visit activity page and see correct activity feed

  • chromium: ❌
  • firefox: ❌

can search on activity page

  • chromium: ❌
  • firefox: ❌

home.onboarded.spec.ts

can visit token detail page

  • chromium: ❌
  • firefox: ❌

leaderboard.logged-in.spec.ts

can visit leaderboard page

  • chromium: ❌
  • firefox: ❌

onboarding.logged-in.spec.ts

can visit onboarding page

  • chromium: ✅
  • firefox: ✅

profile.anon.spec.ts

anon user can visit public profile

  • chromium: ✅
  • firefox: ✅

anon user cannot visit private profile

  • chromium: ✅
  • firefox: ✅

profile.logged-in.spec.ts

logged in user needs onboarding before visiting profile

  • chromium: ✅
  • firefox: ✅

profile.onboarded.spec.ts

can visit other user profile and send by tag

  • chromium: ❌
  • firefox: ✅

can visit my own profile

  • chromium: ❌
  • firefox: ✅

can visit private profile

  • chromium: ❌
  • firefox: 🚨

can view activities between another profile

  • chromium: ❌
  • firefox: ✅

send.onboarded.spec.ts

can send USDC starting from profile page

  • chromium: ❌
  • firefox: 🚨

can send USDC using tag starting from home page

  • chromium: ❌
  • firefox: ✅

can send USDC using sendid starting from home page

  • chromium: ❌
  • firefox: ✅

can send USDC using address starting from home page

  • chromium: ❌
  • firefox: ✅

can send ETH starting from profile page

  • chromium: ❌
  • firefox: ✅

can send ETH using tag starting from home page

  • chromium: ❌
  • firefox: 🚨

can send ETH using sendid starting from home page

  • chromium: ❌
  • firefox: 🚨

can send ETH using address starting from home page

  • chromium: ❌
  • firefox: 🚨

can send SPX starting from profile page

  • chromium: ❌
  • firefox: ✅

can send SPX using tag starting from home page

  • chromium: ❌
    • {
      message: 'An invalid response was received from the upstream server'
      }
  • firefox: ✅

can send SPX using sendid starting from home page

  • chromium: ❌
  • firefox: ✅

can send SPX using address starting from home page

  • chromium: ❌
  • firefox: ✅

can send SEND starting from profile page

  • chromium: ❌
  • firefox: ✅

can send SEND using tag starting from home page

  • chromium: ❌
  • firefox: ✅

can send SEND using sendid starting from home page

  • chromium: ❌
  • firefox: ✅

can send SEND using address starting from home page

  • chromium: ❌
  • firefox: ✅

sign-in.anon.spec.ts

redirect on sign-in

  • chromium: 🚨
  • firefox: ✅

redirect to send confirm page on sign-in

  • chromium: 🚨
  • firefox: ✅

sign-up.anon.spec.ts

can sign up

  • chromium: ✅
  • firefox: ✅

country code is selected based on geoip

  • chromium: ✅
  • firefox: ✅

@musidlo musidlo force-pushed the handle-already-used-phone-in-ui branch from a67c727 to 487007b Compare November 15, 2024 16:32
Copy link
Collaborator

@youngkidwarrior youngkidwarrior left a comment

Choose a reason for hiding this comment

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

Changes look good, a couple touchups here and there.

I would have preferred you split moving the functions and modifying the components into separate PRs so it's easier to pick out the logic from the refactors

)}
</SchemaForm>
)}
{!form.formState.isSubmitSuccessful && !shouldShowBackUpPrompt && signUpForm}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good job on this. Would prefer it to use a switch(true) to make it even more readable.

Here's an example

@@ -1,6 +1,6 @@
import type { inferRouterInputs, inferRouterOutputs } from '@trpc/server'
import { createTRPCRouter } from '../trpc'
import { authRouter } from './auth'
import { authRouter } from './auth/router'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a specific reason to change this route?

Copy link
Author

Choose a reason for hiding this comment

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

yes, I added file for types for auth router and moved both files to auth directory. The reason types cannot be in the same file as router is that it cannot be imported in UI, just like RecoveryOptions

const { mutateAsync: validateSignatureMutateAsync } = api.challenge.validateSignature.useMutation(
{ retry: false }
)

const handleSignIn = async () => {
const handleSignIn = async (isNumberAlreadyUsed = false) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

NIT: maybe should be isPhoneAlreadyUsed to maintain consistency

<Paragraph size="$2" color="$color11">
Already have an account?
</Paragraph>
<SubmitButton onPress={() => handleSignIn()} disabled={isSigningIn} unstyled>
Copy link
Collaborator

Choose a reason for hiding this comment

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

dont have to make this an arrow function since it has no args

onPress={handleSignIn}

is there a reason for the change

Copy link
Author

Choose a reason for hiding this comment

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

actually there is a reason I did that, on press is passing event as a arg to the function, and this function have optional arg, typescript complains about types mismatch between event and function param, and it's right

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah ok I see. Looks good

<ButtonText>YES</ButtonText>
</SubmitButton>
<Button
borderColor="$primary"
Copy link
Collaborator

Choose a reason for hiding this comment

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

for light mode primary is always assigned to black. Unfortunately our tamagui doesn't do this for us yet

Suggested change
borderColor="$primary"
borderColor="$primary"
$theme-light={{borderColor: "$color12"}}

const errorMessage = error.message.toLowerCase()
form.setError('phone', { type: 'custom', message: errorMessage })
}
}

function handleBackUpConfirm() {
const formData = form.getValues()
void signUpWithPhone(formData, true)
Copy link
Collaborator

Choose a reason for hiding this comment

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

NIT: This boolean is a bit magical. Hard to know what it does. Consider using a string enum or passing it in a object so we can name it

})

if (error) {
if (status === AuthStatus.PhoneAlreadyUsed) {
await handleSignIn(true)
Copy link
Collaborator

Choose a reason for hiding this comment

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

See NIT below

w="$12"
onPress={handleBackUpDenial}
>
<Button.Text color="$white" $gtMd={{ color: '$color12' }}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

This won't work on light mode. Instead use our radix-style color pallette

Suggested change
<Button.Text color="$white" $gtMd={{ color: '$color12' }}>
<Button.Text color="$color12">

Copy link
Collaborator

@youngkidwarrior youngkidwarrior left a comment

Choose a reason for hiding this comment

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

Found a bug

const { mutateAsync: validateSignatureMutateAsync } = api.challenge.validateSignature.useMutation(
{ retry: false }
)

const handleSignIn = async () => {
const handleSignIn = async (isNumberAlreadyUsed = false) => {
setIsSigningIn(true)
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is some logical flaw in sign in. If I put the wrong passkey, it pushes me to the Verify Code screen with a phone that exists already

IMG_4202.png

Copy link
Author

Choose a reason for hiding this comment

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

on it

@youngkidwarrior youngkidwarrior changed the base branch from dev to throw-error-when-exisitng-user-uses-otp November 15, 2024 18:22
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants