Enhance web-ui components and styles with new features and dependencies
- Added @lucide/svelte as a dependency for icon support in various components. - Updated AboutDialog, AppShell, AuthPage, Header, SettingsDialog, and styles for improved functionality and UI consistency. - Introduced new props and state management for better user experience. - Refactored CSS for cleaner styling and improved layout.
This commit is contained in:
1 parent
ce6db8a457
commit
e3544617e1
9 files changed
+260
-43
No files matched your search
@@ -39,6 +39,7 @@
|
||||
let identifier = $state('');
|
||||
let password = $state('');
|
||||
let totpToken = $state('');
|
||||
let totpRequired = $state(false);
|
||||
let confirmPassword = $state('');
|
||||
let submitError = $state('');
|
||||
let submitting = $state(false);
|
||||
@@ -47,6 +48,17 @@
|
||||
let resetOpen = $state(false);
|
||||
let resetting = $state(false);
|
||||
|
||||
function isTotpChallenge(caught: unknown): boolean {
|
||||
if (!(caught instanceof Error)) return false;
|
||||
const message = caught.message.toLowerCase();
|
||||
return (
|
||||
message.includes('two-factor authentication code required') ||
|
||||
message.includes('multi-factor authentication code required') ||
|
||||
(message.includes('totp') && message.includes('required')) ||
|
||||
(message.includes('mfa') && message.includes('required'))
|
||||
);
|
||||
}
|
||||
|
||||
async function submit(event: SubmitEvent): Promise<void> {
|
||||
event.preventDefault();
|
||||
submitError = '';
|
||||
@@ -64,10 +76,23 @@
|
||||
await onSetup({ username, email, password });
|
||||
} else {
|
||||
if (!onLogin) throw new Error('The application has not configured its login handler.');
|
||||
if (totpRequired && !totpToken.trim()) {
|
||||
submitError = 'Enter the six-digit authenticator code to continue.';
|
||||
return;
|
||||
}
|
||||
await onLogin({ identifier, password, totpToken: totpToken.trim() });
|
||||
}
|
||||
} catch (caught) {
|
||||
submitError = caught instanceof Error ? caught.message : 'Authentication failed.';
|
||||
if (!setupRequired && showTotp && isTotpChallenge(caught)) {
|
||||
totpRequired = true;
|
||||
submitError = 'Enter the six-digit authenticator code to continue.';
|
||||
} else {
|
||||
if (!setupRequired) {
|
||||
totpRequired = false;
|
||||
totpToken = '';
|
||||
}
|
||||
submitError = caught instanceof Error ? caught.message : 'Authentication failed.';
|
||||
}
|
||||
} finally {
|
||||
submitting = false;
|
||||
}
|
||||
@@ -170,9 +195,9 @@
|
||||
/>
|
||||
</label>
|
||||
|
||||
{#if showTotp && !setupRequired}
|
||||
{#if showTotp && !setupRequired && totpRequired}
|
||||
<label class="sc-field">
|
||||
<span class="sc-label">Authenticator code <span class="sc-label-optional">(if enabled)</span></span>
|
||||
<span class="sc-label">Authenticator code</span>
|
||||
<input
|
||||
autocomplete="one-time-code"
|
||||
class="sc-input"
|
||||
|
||||
Reference in new issue
Block a user