mirror of
https://github.com/shuaiplus/nodewarden.git
synced 2026-06-20 21:00:41 +00:00
feat: add passkey unlock functionality and improve related error handling
This commit is contained in:
@@ -570,6 +570,33 @@ export default function App() {
|
||||
}
|
||||
}
|
||||
|
||||
async function handlePasskeyUnlock() {
|
||||
if (pendingAuthAction) return;
|
||||
const expectedEmail = (profile?.email || session?.email || '').trim().toLowerCase();
|
||||
if (!expectedEmail) return;
|
||||
if (IS_DEMO_MODE) {
|
||||
pushToast('warning', t('txt_demo_readonly_message'));
|
||||
return;
|
||||
}
|
||||
setPendingAuthAction('passkey');
|
||||
try {
|
||||
const result = await performPasskeyLogin(defaultKdfIterations, expectedEmail);
|
||||
if (result.kind === 'success') {
|
||||
await finalizeLogin(result.login, t('txt_unlocked'));
|
||||
return;
|
||||
}
|
||||
if (result.kind === 'password') {
|
||||
pushToast('error', t('txt_account_passkey_direct_unlock_unavailable_error'));
|
||||
return;
|
||||
}
|
||||
pushToast('error', result.message || t('txt_unlock_failed_master_password_is_incorrect'));
|
||||
} catch (error) {
|
||||
pushToast('error', error instanceof Error ? error.message : t('txt_unlock_failed_master_password_is_incorrect'));
|
||||
} finally {
|
||||
setPendingAuthAction(null);
|
||||
}
|
||||
}
|
||||
|
||||
async function handlePasskeyPasswordLogin() {
|
||||
if (pendingAuthAction || !pendingPasskeyPassword) return;
|
||||
if (!passkeyPassword) {
|
||||
@@ -1720,6 +1747,7 @@ export default function App() {
|
||||
onChangeUnlock={setUnlockPassword}
|
||||
onSubmitLogin={() => void handleLogin()}
|
||||
onSubmitPasskey={() => void handlePasskeyLogin()}
|
||||
onSubmitPasskeyUnlock={() => void handlePasskeyUnlock()}
|
||||
onSubmitPasskeyPassword={() => void handlePasskeyPasswordLogin()}
|
||||
onSubmitRegister={() => void handleRegister()}
|
||||
onSubmitUnlock={() => void handleUnlock()}
|
||||
|
||||
Reference in New Issue
Block a user