Skip to content

Commit 0c70a29

Browse files
committed
fix: improve auth error handling and update modal styles for better user experience
1 parent 67f94aa commit 0c70a29

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

src/features/auth/components/authModal.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@
2828
border-radius: 6px;
2929
padding: 8px;
3030
display: flex;
31+
justify-content: center;
3132
flex-direction: row;
3233
p {
3334
padding: 0;
3435
margin: 0;
3536
font-size: 0.8em;
3637
color: red;
38+
text-align: center;
3739
}
3840
.cta {
3941
flex: 1;

src/providers/AuthProvider.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { firebaseAuth } from 'src/lib/firebase'
88
export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
99
const navigate = useNavigate()
1010
const [searchParams] = useSearchParams()
11-
const { closeAuthModal, initState, setAuthError } = useAuth()
11+
const { closeAuthModal, initState, setAuthError, openAuthModal } = useAuth()
1212

1313
const connectTheUser = useCallback((token?: string | null, provider?: string | null) => {
1414
const allowedProviders = ['google', 'github']
@@ -78,16 +78,16 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
7878
const token = searchParams.get('access_token')
7979
const provider = searchParams.get('provider')
8080
connectTheUser(token, provider).catch((error) => {
81+
openAuthModal()
8182
if (error && error.code === 'auth/account-exists-with-different-credential') {
82-
toast(
83-
'You have an account with a different provider. Please sign in with that provider to continue.',
84-
{
85-
theme: 'dangerToast',
86-
}
87-
)
83+
setAuthError({
84+
message:
85+
'You have an account with a different provider. Please sign in with that provider to continue.',
86+
})
8887
} else {
89-
console.log(error)
90-
toast('Error signing in, Please try again', { theme: 'dangerToast' })
88+
setAuthError({
89+
message: 'Error signing in, Please try again',
90+
})
9191
}
9292
})
9393
}, [searchParams])

0 commit comments

Comments
 (0)