Browse Source

🚸 Improve login (#1163)

pull/13907/head
Patrick Arminio 1 year ago
committed by GitHub
parent
commit
9523db2f53
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      frontend/src/hooks/useAuth.ts
  2. 12
      frontend/src/routes/login.tsx

1
frontend/src/hooks/useAuth.ts

@ -58,6 +58,7 @@ const useAuth = () => {
user, user,
isLoading, isLoading,
error, error,
resetError: () => setError(null),
} }
} }

12
frontend/src/routes/login.tsx

@ -38,7 +38,7 @@ export const Route = createFileRoute("/login")({
function Login() { function Login() {
const [show, setShow] = useBoolean() const [show, setShow] = useBoolean()
const { loginMutation, error } = useAuth() const { loginMutation, error, resetError } = useAuth()
const { const {
register, register,
handleSubmit, handleSubmit,
@ -53,7 +53,15 @@ function Login() {
}) })
const onSubmit: SubmitHandler<AccessToken> = async (data) => { const onSubmit: SubmitHandler<AccessToken> = async (data) => {
loginMutation.mutate(data) if (isSubmitting) return
resetError()
try {
await loginMutation.mutateAsync(data)
} catch {
// error is handled by useAuth hook
}
} }
return ( return (

Loading…
Cancel
Save