Skip to content

Commit

Permalink
fix legacy email auth's finalizeAuth (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrislav authored Jun 14, 2024
1 parent 56093e9 commit 4a19c35
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/utils/useEmailAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ export function useEmailAuth({ onSuccess }: { onSuccess: (idToken: string) => vo

try {
const sessionHash = await sequence.getSessionHash()
const { idToken } = await sequence.email.finalizeAuth({ instance, answer, email, sessionHash })
onSuccess(idToken)
const identity = await sequence.email.finalizeAuth({ instance, answer, email, sessionHash })
if (!('idToken' in identity)) {
throw new Error("invalid identity returned by finalizeAuth")
}
onSuccess(identity.idToken)
} catch (e: any) {
setError(e.message || "Unknown error")
} finally {
Expand Down

0 comments on commit 4a19c35

Please sign in to comment.