mirror of
https://github.com/shuaiplus/nodewarden.git
synced 2026-06-22 21:50:13 +00:00
fix: refine login success toast handling
This commit is contained in:
+6
-7
@@ -505,7 +505,7 @@ export default function App() {
|
|||||||
};
|
};
|
||||||
}, [phase, session?.email, location, navigate]);
|
}, [phase, session?.email, location, navigate]);
|
||||||
|
|
||||||
async function finalizeLogin(login: CompletedLogin, successMessage = t('txt_login_success')) {
|
async function finalizeLogin(login: CompletedLogin) {
|
||||||
setSession(login.session);
|
setSession(login.session);
|
||||||
setProfile(login.profile);
|
setProfile(login.profile);
|
||||||
setUnlockPreparing(false);
|
setUnlockPreparing(false);
|
||||||
@@ -519,7 +519,6 @@ export default function App() {
|
|||||||
if (location === '/' || location === '/login' || location === '/register' || location === '/lock') {
|
if (location === '/' || location === '/login' || location === '/register' || location === '/lock') {
|
||||||
navigate('/vault');
|
navigate('/vault');
|
||||||
}
|
}
|
||||||
pushToast('success', successMessage);
|
|
||||||
void (async () => {
|
void (async () => {
|
||||||
try {
|
try {
|
||||||
const hydratedProfile = await login.profilePromise;
|
const hydratedProfile = await login.profilePromise;
|
||||||
@@ -536,7 +535,7 @@ export default function App() {
|
|||||||
if (IS_DEMO_MODE) {
|
if (IS_DEMO_MODE) {
|
||||||
setPendingAuthAction('login');
|
setPendingAuthAction('login');
|
||||||
try {
|
try {
|
||||||
await finalizeLogin(createDemoCompletedLogin(loginValues.email), t('txt_login_success'));
|
await finalizeLogin(createDemoCompletedLogin(loginValues.email));
|
||||||
} finally {
|
} finally {
|
||||||
setPendingAuthAction(null);
|
setPendingAuthAction(null);
|
||||||
}
|
}
|
||||||
@@ -608,7 +607,7 @@ export default function App() {
|
|||||||
try {
|
try {
|
||||||
const result = await performPasskeyLogin(defaultKdfIterations, expectedEmail);
|
const result = await performPasskeyLogin(defaultKdfIterations, expectedEmail);
|
||||||
if (result.kind === 'success') {
|
if (result.kind === 'success') {
|
||||||
await finalizeLogin(result.login, t('txt_unlocked'));
|
await finalizeLogin(result.login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (result.kind === 'password') {
|
if (result.kind === 'password') {
|
||||||
@@ -650,7 +649,7 @@ export default function App() {
|
|||||||
setTotpSubmitting(true);
|
setTotpSubmitting(true);
|
||||||
try {
|
try {
|
||||||
const login = await performTotpLogin(pendingTotp, totpCode, rememberDevice);
|
const login = await performTotpLogin(pendingTotp, totpCode, rememberDevice);
|
||||||
await finalizeLogin(login, pendingTotpMode === 'unlock' ? t('txt_unlocked') : t('txt_login_success'));
|
await finalizeLogin(login);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
pushToast('error', error instanceof Error ? error.message : t('txt_totp_verify_failed'));
|
pushToast('error', error instanceof Error ? error.message : t('txt_totp_verify_failed'));
|
||||||
} finally {
|
} finally {
|
||||||
@@ -790,7 +789,7 @@ export default function App() {
|
|||||||
if (IS_DEMO_MODE) {
|
if (IS_DEMO_MODE) {
|
||||||
setPendingAuthAction('unlock');
|
setPendingAuthAction('unlock');
|
||||||
try {
|
try {
|
||||||
await finalizeLogin(createDemoCompletedLogin(session.email), t('txt_unlocked'));
|
await finalizeLogin(createDemoCompletedLogin(session.email));
|
||||||
} finally {
|
} finally {
|
||||||
setPendingAuthAction(null);
|
setPendingAuthAction(null);
|
||||||
}
|
}
|
||||||
@@ -804,7 +803,7 @@ export default function App() {
|
|||||||
try {
|
try {
|
||||||
const result = await performUnlock(session, profile, unlockPassword, defaultKdfIterations);
|
const result = await performUnlock(session, profile, unlockPassword, defaultKdfIterations);
|
||||||
if (result.kind === 'success') {
|
if (result.kind === 'success') {
|
||||||
await finalizeLogin(result.login, t('txt_unlocked'));
|
await finalizeLogin(result.login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (result.kind === 'totp') {
|
if (result.kind === 'totp') {
|
||||||
|
|||||||
Reference in New Issue
Block a user