Skip to content

Commit

Permalink
feat: better error handling of webauthn (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
itsHenry35 authored Mar 10, 2024
1 parent 0946e6a commit e52e8f4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
28 changes: 18 additions & 10 deletions src/pages/login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,25 @@ const Login = () => {
}
const resp = await getauthntemp(username())
handleResp(resp, async (data) => {
const options = parseRequestOptionsFromJSON(data.options)
const credentials = await get(options)
const resp = await postauthnlogin(data.session, credentials, username())
handleRespWithoutNotify(resp, (data) => {
notify.success(t("login.success"))
changeToken(data.token)
to(
decodeURIComponent(searchParams.redirect || base_path || "/"),
true,
try {
const options = parseRequestOptionsFromJSON(data.options)
const credentials = await get(options)
const resp = await postauthnlogin(
data.session,
credentials,
username(),
)
})
handleRespWithoutNotify(resp, (data) => {
notify.success(t("login.success"))
changeToken(data.token)
to(
decodeURIComponent(searchParams.redirect || base_path || "/"),
true,
)
})
} catch (error: unknown) {
if (error instanceof Error) notify.error(error.message)
}
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/manage/users/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ const Profile = () => {
return
}
const resp = await getauthntemp()
handleRespWithoutNotify(resp, async (data) => {
handleResp(resp, async (data) => {
const options = parseCreationOptionsFromJSON(data.options)
const session = data.session
try {
Expand Down

0 comments on commit e52e8f4

Please sign in to comment.