M1.5 frontend: admin Settings UI + config store + register gating
- config store (public /api/config: site_name, allow_registration, version), loaded in the router guard; site name drives the board header. - session User gains is_admin. - /settings route with requiresAdmin guard + admin-only gear link in the header; SettingsView renders grouped typed fields (text/number/toggle), saves via PATCH /api/settings with saved/error feedback, refreshes public config. - Register link hidden + /register route blocked when registration is closed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FRgehjoz7Yv8LkUfADxACm
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { ref } from "vue";
|
||||
import { api } from "../api/client";
|
||||
|
||||
interface PublicConfig {
|
||||
site_name: string;
|
||||
allow_registration: boolean;
|
||||
version: string;
|
||||
}
|
||||
|
||||
// Public, unauthenticated app config (site name, whether signups are open).
|
||||
export const useConfigStore = defineStore("config", () => {
|
||||
const siteName = ref("ThoughtSync");
|
||||
const allowRegistration = ref(true);
|
||||
const version = ref("");
|
||||
const loaded = ref(false);
|
||||
|
||||
async function load(): Promise<void> {
|
||||
if (loaded.value) return;
|
||||
try {
|
||||
const cfg = await api.get<PublicConfig>("/api/config");
|
||||
siteName.value = cfg.site_name;
|
||||
allowRegistration.value = cfg.allow_registration;
|
||||
version.value = cfg.version;
|
||||
} catch {
|
||||
// Keep defaults if the config endpoint is unreachable.
|
||||
} finally {
|
||||
loaded.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
async function reload(): Promise<void> {
|
||||
loaded.value = false;
|
||||
await load();
|
||||
}
|
||||
|
||||
return { siteName, allowRegistration, version, loaded, load, reload };
|
||||
});
|
||||
@@ -7,6 +7,7 @@ export interface User {
|
||||
email: string;
|
||||
display_name: string;
|
||||
email_verified: boolean;
|
||||
is_admin: boolean;
|
||||
}
|
||||
|
||||
export const useSessionStore = defineStore("session", () => {
|
||||
|
||||
Reference in New Issue
Block a user