mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-30 00:19:35 +00:00
feat(web): add password setup page, change password, and settings tabs
- First-time visitors see a password setup page instead of open access - Password persisted to SQLite (env var DBX_PASSWORD takes priority) - Add change password in settings dialog (Security tab, web only) - Split settings dialog into Editor and Security tabs - Argon2 hashing for all password storage
This commit is contained in:
+11
-3
@@ -59,6 +59,7 @@ const { setupFileDrop } = useFileDrop();
|
||||
const isDesktop = isTauriRuntime();
|
||||
const needsAuth = ref(!isDesktop);
|
||||
const authenticated = ref(isDesktop);
|
||||
const setupRequired = ref(false);
|
||||
|
||||
const showConnectionDialog = ref(false);
|
||||
const showSettingsDialog = ref(false);
|
||||
@@ -296,6 +297,8 @@ function handleKeydown(e: KeyboardEvent) {
|
||||
|
||||
function onLoginSuccess() {
|
||||
authenticated.value = true;
|
||||
setupRequired.value = false;
|
||||
needsAuth.value = true;
|
||||
window.history.replaceState(null, "", "/");
|
||||
initApp();
|
||||
}
|
||||
@@ -336,13 +339,14 @@ onMounted(async () => {
|
||||
const data = await res.json();
|
||||
needsAuth.value = data.required;
|
||||
authenticated.value = data.authenticated;
|
||||
setupRequired.value = data.setup_required;
|
||||
} catch {
|
||||
/* server unreachable */
|
||||
}
|
||||
if (needsAuth.value && !authenticated.value) {
|
||||
history.replaceState(null, "", "/login");
|
||||
}
|
||||
if (!needsAuth.value || authenticated.value) initApp();
|
||||
if (!setupRequired.value && (!needsAuth.value || authenticated.value)) initApp();
|
||||
api
|
||||
.getAppVersion()
|
||||
.then((v) => {
|
||||
@@ -369,8 +373,12 @@ onUnmounted(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<LoginPage v-if="needsAuth && !authenticated" @authenticated="onLoginSuccess" />
|
||||
<div v-show="!needsAuth || authenticated">
|
||||
<LoginPage
|
||||
v-if="setupRequired || (needsAuth && !authenticated)"
|
||||
:setup-mode="setupRequired"
|
||||
@authenticated="onLoginSuccess"
|
||||
/>
|
||||
<div v-show="!setupRequired && (!needsAuth || authenticated)">
|
||||
<TooltipProvider :delay-duration="300">
|
||||
<div class="h-screen w-screen flex flex-col bg-background text-foreground overflow-hidden">
|
||||
<AppToolbar
|
||||
|
||||
Reference in New Issue
Block a user