Fix: make locals global
All checks were successful
Build Docker Image / run (pull_request) Successful in 51s

This commit is contained in:
Clement 2024-04-26 17:05:16 +02:00
parent 41ed285326
commit 9a4357394a
5 changed files with 18 additions and 14 deletions

15
front/src/env.d.ts vendored
View File

@ -16,10 +16,17 @@ interface ImportMeta {
}
// eslint-disable-next-line @typescript-eslint/no-namespace
declare namespace App {
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface Locals {
// declare namespace App {
// interface Locals {
// pb: PocketBase
// }
// }
declare global {
namespace App {
interface Locals {
pb: PocketBase
}
}
}

View File

@ -3,7 +3,7 @@ import Layout from 'layouts/Layout.astro'
import PocketBase from 'pocketbase'
const pb = Astro.locals.pb as PocketBase
const pb = Astro.locals.pb
const auth = pb.authStore
const user = auth.model

View File

@ -4,7 +4,7 @@ import AstroUtils from "libs/AstroUtils";
import PocketBase from 'pocketbase'
const pb = Astro.locals.pb as PocketBase
const pb = Astro.locals.pb
if(pb.authStore.isValid){
return Astro.redirect("/account")
@ -14,9 +14,6 @@ const res = await AstroUtils.wrap(async () => {
if (Astro.request.method !== 'POST') {
return
}
// FIXME checké si utilisateur deja connecté
const locals = Astro.locals
const form = await Astro.request.formData();
const request = {
user: form.get("username") as string,

View File

@ -2,7 +2,7 @@
import PocketBase from 'pocketbase'
const pb = Astro.locals.pb as PocketBase
const pb = Astro.locals.pb
if(pb.authStore.isValid){
pb.authStore.clear()

View File

@ -4,7 +4,7 @@ import AstroUtils from 'libs/AstroUtils';
import PocketBase from 'pocketbase'
const pb = Astro.locals.pb as PocketBase
const pb = Astro.locals.pb
if(pb.authStore.isValid){
return Astro.redirect("/account")