You've already forked obsidian-visualiser
Tests connexion
This commit is contained in:
@@ -7,18 +7,22 @@ function toggleLeftPanel(_: Event) {
|
||||
|
||||
<script setup lang="ts">
|
||||
const { hash, path } = useRoute();
|
||||
const route = path.substring(path.indexOf('/explorer') + '/explorer'.length);
|
||||
|
||||
const { data: page } = await useAsyncData('home', queryContent(path.substring(path.indexOf('/explorer') + '/explorer'.length)).findOne);
|
||||
const { data: page } = await useAsyncData('home', queryContent(route).findOne);
|
||||
const { data: comments } = await useFetch(`/api/comments`, {
|
||||
query: {
|
||||
route: route
|
||||
}
|
||||
});
|
||||
|
||||
if(page.value)
|
||||
useContentHead(page.value!);
|
||||
|
||||
if(hash)
|
||||
{
|
||||
console.log(document.getElementById(hash.substring(1)));
|
||||
document.getElementById(hash.substring(1))?.scrollTo({ behavior: 'smooth', top: 100 });
|
||||
useContentHead(page.value!);
|
||||
}
|
||||
|
||||
const content = ref();
|
||||
|
||||
onMounted(() => {
|
||||
document.querySelectorAll('.callout.is-collapsible .callout-title').forEach(e => {
|
||||
e.addEventListener('click', (_) => {
|
||||
@@ -53,7 +57,7 @@ onMounted(() => {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<RightComponent v-if="page.body?.toc" :toc="page?.body?.toc" />
|
||||
<RightComponent v-if="page.body?.toc" :toc="page?.body?.toc" :comments="comments" />
|
||||
</template>
|
||||
<CanvasRenderer v-else-if="!!page && page._type == 'canvas'" :key="page._id" :canvas="page" />
|
||||
<div v-else-if="!!page">
|
||||
|
||||
@@ -1,14 +1,70 @@
|
||||
<script setup lang="ts">
|
||||
definePageMeta({
|
||||
auth: {
|
||||
unauthenticatedOnly: true,
|
||||
navigateAuthenticatedTo: '/user/profile'
|
||||
import { schema, type Login } from '~/schemas/login';
|
||||
|
||||
definePageMeta({
|
||||
auth: {
|
||||
disconnectedOnly: true,
|
||||
connectedRedirect: '/user/profile'
|
||||
}
|
||||
});
|
||||
|
||||
const state = reactive<Login>({
|
||||
username: '',
|
||||
password: ''
|
||||
});
|
||||
|
||||
const { status, login } = useAuth();
|
||||
|
||||
const usernameError = ref("");
|
||||
const passwordError = ref("");
|
||||
|
||||
async function submit()
|
||||
{
|
||||
const data = schema.safeParse(state);
|
||||
|
||||
if(data.success && state.password !== "")
|
||||
{
|
||||
let errors = await login(data.data.username, data.data.password);
|
||||
|
||||
if(status.value === AuthStatus.connected)
|
||||
{
|
||||
await navigateTo('/user/profile', { replace: true });
|
||||
}
|
||||
else
|
||||
{
|
||||
errors = errors?.issues ?? errors;
|
||||
usernameError.value = errors?.find((e: any) => e.path.includes("username"))?.message ?? "";
|
||||
passwordError.value = errors?.find((e: any) => e.path.includes("password"))?.message ?? "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
usernameError.value = data.error?.issues.find(e => e.path.includes("username"))?.message ?? "";
|
||||
passwordError.value = data.error?.issues.find(e => e.path.includes("password"))?.message ?? "";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Head>
|
||||
<Title>Se connecter</Title>
|
||||
</Head>
|
||||
<div class="site-body-center-column">
|
||||
<div class="render-container flex align-center justify-center">
|
||||
<form v-if="status === AuthStatus.disconnected" @submit.prevent="submit" class="input-form input-form-wide">
|
||||
<h1>Connexion</h1>
|
||||
<Input type="text" autocomplete="username" v-model="state.username"
|
||||
placeholder="" title="Nom d'utilisateur ou adresse mail" :error="usernameError" />
|
||||
<Input type="password" autocomplete="current-password" v-model="state.password"
|
||||
placeholder="" title="Mot de passe"
|
||||
:error="passwordError" />
|
||||
<button>Se connecter</button>
|
||||
<NuxtLink to="/user/register">Pas de compte ?</NuxtLink>
|
||||
</form>
|
||||
<div v-else-if="status === AuthStatus.loading" class="input-form"><div class="loading"></div></div>
|
||||
<div v-else class="not-found-container">
|
||||
<div class="not-found-title">👀 Vous n'avez rien à faire ici. 👀</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,8 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
definePageMeta({
|
||||
auth: {
|
||||
unauthenticatedOnly: false,
|
||||
navigateUnauthenticatedTo: '/user/login'
|
||||
disconnectedOnly: false,
|
||||
disconnectedRedirect: '/user/login'
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ import { schema, type Registration } from '~/schemas/registration';
|
||||
|
||||
definePageMeta({
|
||||
auth: {
|
||||
unauthenticatedOnly: true,
|
||||
navigateAuthenticatedTo: '/user/profile'
|
||||
disconnectedOnly: true,
|
||||
connectedRedirect: '/user/profile'
|
||||
}
|
||||
});
|
||||
|
||||
@@ -86,7 +86,8 @@ async function submit()
|
||||
<Input type="password" v-model="confirmPassword" placeholder="Confirmer le mot de passe"
|
||||
title="Confirmer le mot de passe"
|
||||
:error="confirmPassword === '' || confirmPassword === state.password ? '' : 'Les mots de passe saisies ne sont pas identique'" />
|
||||
<button>Valider</button>
|
||||
<button>S'inscrire</button>
|
||||
<NuxtLink to="/user/login">Se connecter</NuxtLink>
|
||||
</form>
|
||||
<div v-else-if="status === AuthStatus.loading" class="input-form"><div class="loading"></div></div>
|
||||
<div v-else class="not-found-container">
|
||||
|
||||
Reference in New Issue
Block a user