Skip to content

Commit 3bdacbe

Browse files
authored
app auth fixes and cleanup (#469)
* app: fix recovery link on sign in * app: auth sign in form UI tweaks also refactors * fix type error, more ui clean up UX feedback on success * app: clean up sidebars * fix spec
1 parent 66643e8 commit 3bdacbe

File tree

12 files changed

+188
-173
lines changed

12 files changed

+188
-173
lines changed

packages/api/src/routers/account-recovery/router.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ const verifyRecoverySignature = async (
172172
if (recoveryType === RecoveryOptions.EOA) {
173173
verified = await verifyMessage({
174174
address: identifier as `0x${string}`,
175-
message: RecoveryEOAPreamble + byteaToHex(challengeData.challenge),
175+
message: RecoveryEOAPreamble + byteaToHex(challengeData.challenge as `\\x${string}`),
176176
signature: signature,
177177
})
178178
} else if (recoveryType === RecoveryOptions.WEBAUTHN) {

packages/app/components/sidebar/AuthSideBar.tsx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { SideBar, SideBarWrapper, Stack, Theme, YStack, type YStackProps, useMedia } from '@my/ui'
1+
import { SideBar, Stack, Theme, YStack, useMedia, type YStackProps, XStack } from '@my/ui'
22
import { IconSendLogo } from 'app/components/icons'
33
import { SignInForm } from 'app/features/auth/sign-in/sign-in-form'
44
import { OnboardingForm } from 'app/features/auth/onboarding/onboarding-form'
@@ -27,15 +27,10 @@ const AuthSideBar = ({ ...props }: YStackProps) => {
2727

2828
export const AuthSideBarWrapper = ({ children }: { children?: React.ReactNode }) => {
2929
const media = useMedia()
30-
if (media.gtMd) {
31-
return (
32-
<SideBarWrapper
33-
overflow="hidden"
34-
sidebar={<AuthSideBar bc={'$background'} h={'92%'} ml={'$7'} my={'auto'} br={'$8'} />}
35-
>
36-
{children}
37-
</SideBarWrapper>
38-
)
39-
}
40-
return children
30+
return (
31+
<XStack overflow="hidden" height={'100%'}>
32+
{media.gtMd && <AuthSideBar bc={'$background'} h={'92%'} ml={'$7'} my={'auto'} br={'$8'} />}
33+
{children}
34+
</XStack>
35+
)
4136
}

packages/app/components/sidebar/HomeSideBar.tsx

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
ScrollView,
88
Separator,
99
SideBar,
10-
SideBarWrapper,
1110
XStack,
1211
YStack,
1312
useMedia,
@@ -127,18 +126,13 @@ const HomeBottomSheet = () => {
127126
export const HomeSideBarWrapper = ({ children }: { children?: React.ReactNode }) => {
128127
const media = useMedia()
129128

130-
if (media.gtLg)
131-
return (
132-
<SideBarWrapper
133-
sidebar={<HomeSideBar bc="$color2" width={234} minWidth={234} pt={80} jc="flex-start" />}
134-
>
135-
{children}
136-
</SideBarWrapper>
137-
)
138129
return (
139-
<>
140-
<HomeBottomSheet />
130+
<XStack overflow="hidden" height={'100%'}>
131+
{media.gtLg && (
132+
<HomeSideBar bc="$color2" width={234} minWidth={234} pt={80} jc="flex-start" />
133+
)}
141134
{children}
142-
</>
135+
<HomeBottomSheet />
136+
</XStack>
143137
)
144138
}

packages/app/features/auth/account-recovery/account-recovery.tsx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useEffect, useState, useCallback } from 'react'
22
import RecoverWithEOA from 'app/features/auth/account-recovery/eoa/RecoverWithEOA'
3-
import { Stack, XStack, YStack, Text, Button, ButtonText } from '@my/ui'
3+
import { Stack, XStack, YStack, Text, Button, ButtonText, useToastController } from '@my/ui'
44
import type {
55
ChallengeResponse,
66
VerifyChallengeRequest,
@@ -11,7 +11,7 @@ import { api } from 'app/utils/api'
1111
import { IconError, IconRefresh } from 'app/components/icons'
1212
import { useRouter } from 'solito/router'
1313
import RecoverWithPasskey from 'app/features/auth/account-recovery/passkey/RecoverWithPasskey'
14-
import type { SignMessageErrorType } from 'viem'
14+
import type { SignMessageErrorType } from '@wagmi/core'
1515

1616
interface Props {
1717
onClose?: () => void
@@ -24,6 +24,7 @@ export enum SignState {
2424
}
2525

2626
export default function AccountRecovery(props: Props) {
27+
const toast = useToastController()
2728
const [error, setError] = useState<ErrorWithMessage>()
2829
// TODO: frontend: implement signing loading state
2930
const [signState, setSignState] = useState<SignState>(SignState.NOT_COMPLETE)
@@ -55,14 +56,15 @@ export default function AccountRecovery(props: Props) {
5556
...verifyChallengeRequest,
5657
})
5758
.then(() => {
59+
toast.show('Successfully recovered your account')
5860
// JWT is set via Set-Cookie header
5961
router.push('/')
6062
})
6163
.catch((err) => {
6264
setError(err)
6365
})
6466
},
65-
[validateSignatureMutateAsync, router]
67+
[validateSignatureMutateAsync, router, toast]
6668
)
6769

6870
const onSignError = (e: SignMessageErrorType) => {
@@ -122,20 +124,13 @@ export default function AccountRecovery(props: Props) {
122124
}
123125

124126
return (
125-
<YStack mt={'0'} w={'100%'} h={'100%'} jc={'space-between'}>
127+
<YStack mt={'0'} w={'100%'} h={'100%'} jc={'space-between'} maxWidth={600} mx="auto" pb="$6">
126128
<Stack flex={1} jc={'center'} alignItems="center" gap="$2">
127129
{showHeading()}
128130
{!error && challengeData && showRecoveryOptions()}
129131
</Stack>
130132

131-
<Button
132-
w={'100%'}
133-
backgroundColor={'$primary'}
134-
hoverStyle={{ backgroundColor: '$primary' }}
135-
pressStyle={{ backgroundColor: '$primary' }}
136-
focusStyle={{ backgroundColor: '$primary' }}
137-
onPress={props.onClose}
138-
>
133+
<Button w={'100%'} theme="accent" onPress={props.onClose}>
139134
<ButtonText>RETURN</ButtonText>
140135
</Button>
141136
</YStack>

packages/app/features/auth/account-recovery/eoa/RecoverWithEOA.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ import {
99
} from '@my/api/src/routers/account-recovery/types'
1010
import type { SignState } from 'app/features/auth/account-recovery/account-recovery'
1111
import { RecoveryEOAPreamble } from '@my/api/src/routers/account-recovery/types'
12+
import type { SignMessageErrorType } from '@wagmi/core'
1213

1314
interface Props {
1415
challengeData: ChallengeResponse
1516
signState: SignState
1617

1718
onSignSuccess: (args: VerifyChallengeRequest) => Promise<void>
18-
onSignError: () => void
19+
onSignError: (e: SignMessageErrorType) => void
1920
}
2021

2122
export default function RecoverWithEOA(props: Props) {
@@ -51,8 +52,8 @@ export default function RecoverWithEOA(props: Props) {
5152
}
5253

5354
return (
54-
<OpenConnectModalWrapper>
55-
<Button onPress={isConnected ? onPress : null} width={'$12'}>
55+
<OpenConnectModalWrapper width={'50%'}>
56+
<Button onPress={isConnected ? onPress : null}>
5657
<ButtonText testID="account-recovery-eoa-btn">EOA</ButtonText>
5758
</Button>
5859
</OpenConnectModalWrapper>

packages/app/features/auth/account-recovery/passkey/RecoverWithPasskey.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ import {
66
type VerifyChallengeRequest,
77
} from '@my/api/src/routers/account-recovery/types'
88
import { bytesToHex, hexToBytes } from 'viem'
9+
import type { SignMessageErrorType } from '@wagmi/core'
910

1011
interface Props {
1112
challengeData: ChallengeResponse
1213
onSignSuccess: (args: VerifyChallengeRequest) => void
1314
// https://wagmi.sh/react/api/hooks/useSignMessage#onerror
14-
onSignError: () => void
15+
onSignError: (e: SignMessageErrorType) => void
1516
}
1617

1718
export default function RecoverWithPasskey(props: Props) {

0 commit comments

Comments
 (0)