Use the authentication method system for the demo login and the generated accounts. This makes it possible to toggle it off on production systems as these shouldn't have it enabled at all.
41 lines
853 B
Vue
41 lines
853 B
Vue
<!--
|
|
SPDX-FileCopyrightText: © 2025 Hornwitser <code@hornwitser.no>
|
|
SPDX-License-Identifier: AGPL-3.0-or-later
|
|
-->
|
|
<template>
|
|
<form @submit.prevent="logIn">
|
|
<label>
|
|
Demo:
|
|
<input v-model="name" type="text" placeholder="Name" required>
|
|
<button type="submit">Log In</button>
|
|
</label>
|
|
</form>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
const sessionStore = useSessionStore();
|
|
const route = useRoute();
|
|
|
|
const name = ref("");
|
|
async function logIn() {
|
|
try {
|
|
const session = await $fetch("/api/auth/ap/demo-login", {
|
|
method: "POST",
|
|
body: { name: name.value },
|
|
});
|
|
await sessionStore.update(session);
|
|
if (!session.account) {
|
|
await navigateTo("/register");
|
|
} else if (route.path === "/register") {
|
|
await navigateTo("/");
|
|
}
|
|
|
|
} catch (err: any) {
|
|
alert(err.data?.message ?? err.message);
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
|
|
</style>
|