From 65598bceac38d8e2734355d72c47be3bc6755ea3 Mon Sep 17 00:00:00 2001 From: florianfederspiel Date: Sun, 9 Nov 2025 18:27:09 +0100 Subject: [PATCH 1/3] Fix Auth --- stores/auth.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/stores/auth.ts b/stores/auth.ts index 7f6a38a..864d6e0 100644 --- a/stores/auth.ts +++ b/stores/auth.ts @@ -34,11 +34,15 @@ export const useAuthStore = defineStore("auth", { body: { email, password } }) if(useCapacitor().getIsNative()) { + console.log("On Native") await Preferences.set({ key:"token", value: token, }) + useCookie("token").value = token // persistieren + } else { + console.log("On Web") useCookie("token").value = token // persistieren } From 3cd7120b4b69f35f1912f0d9660b2d3011d1e229 Mon Sep 17 00:00:00 2001 From: florianfederspiel Date: Sun, 9 Nov 2025 18:38:31 +0100 Subject: [PATCH 2/3] Changed DC --- docker-compose.yml | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 55aab3b..8e31979 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,26 +3,4 @@ version: "3" services: web: image: reg.federspiel.software/fedeo/software:beta - restart: always -# networks: -# - traefik - environment: - NUXT_PUBLIC_API_BASE: "https://backend.fedeo.io" - # labels: -# - "traefik.enable=true" -# - "traefik.docker.network=traefik" -# - "traefik.port=3000" -# # Middlewares -# - "traefik.http.middlewares.spaces-frontend-redirect-web-secure.redirectscheme.scheme=https" -# # Web Entrypoint -# - "traefik.http.routers.spaces-frontend.middlewares=spaces-frontend-redirect-web-secure" -# - "traefik.http.routers.spaces-frontend.rule=Host(`app.spaces.software`)" -# - "traefik.http.routers.spaces-frontend.entrypoints=web" -# # Web Secure Entrypoint -# - "traefik.http.routers.spaces-frontend-secure.rule=Host(`app.spaces.software`)" -# - "traefik.http.routers.spaces-frontend-secure.entrypoints=web-secured" # -# - "traefik.http.routers.spaces-frontend-secure.tls.certresolver=mytlschallenge" - -#networks: -# traefik: -# external: true \ No newline at end of file + restart: always \ No newline at end of file From 06b97cbdaefefa86b1e4f6eb90d131a7635c3e34 Mon Sep 17 00:00:00 2001 From: florianfederspiel Date: Sun, 9 Nov 2025 19:51:32 +0100 Subject: [PATCH 3/3] Changed Auth --- plugins/auth-init.client.ts | 7 +++- stores/auth.ts | 73 ++++++++++++++++++++++++------------- 2 files changed, 54 insertions(+), 26 deletions(-) diff --git a/plugins/auth-init.client.ts b/plugins/auth-init.client.ts index 68affde..6eedbe0 100644 --- a/plugins/auth-init.client.ts +++ b/plugins/auth-init.client.ts @@ -1,4 +1,9 @@ export default defineNuxtPlugin(async () => { const auth = useAuthStore() - await auth.init() + + console.log("Auth init") + + await auth.initStore() + + }) \ No newline at end of file diff --git a/stores/auth.ts b/stores/auth.ts index 864d6e0..052a66d 100644 --- a/stores/auth.ts +++ b/stores/auth.ts @@ -11,28 +11,11 @@ export const useAuthStore = defineStore("auth", { activeTenant: null as any, activeTenantData: null as any, loading: true as boolean, + notLoggedIn: true, }), actions: { - async init(token) { - await this.fetchMe(token) - - const tempStore = useTempStore() - - if(this.profile.temp_config) tempStore.setStoredTempConfig(this.profile.temp_config) - - if(useCapacitor().getIsNative()) { - navigateTo("/mobile") - } else { - navigateTo("/") - } - }, - - async login(email: string, password: string) { - const { token } = await useNuxtApp().$api("/auth/login", { - method: "POST", - body: { email, password } - }) + async persist(token) { if(useCapacitor().getIsNative()) { console.log("On Native") await Preferences.set({ @@ -46,10 +29,54 @@ export const useAuthStore = defineStore("auth", { useCookie("token").value = token // persistieren } + }, + + async initStore() { + console.log("Auth initStore") + await this.fetchMe() + + const tempStore = useTempStore() + + if(this.profile.temp_config) tempStore.setStoredTempConfig(this.profile.temp_config) + if(this.activeTenant > 0) { + this.loading = false + if(useCapacitor().getIsNative()) { + navigateTo("/mobile") + } else { + navigateTo("/") + } + } + }, + + async init(token=null) { + console.log("Auth init") + await this.fetchMe(token) + + const tempStore = useTempStore() + + if(this.profile.temp_config) tempStore.setStoredTempConfig(this.profile.temp_config) + if(this.activeTenant > 0) { + this.loading = false + if(useCapacitor().getIsNative()) { + navigateTo("/mobile") + } else { + navigateTo("/") + } + } + }, + + async login(email: string, password: string) { + console.log("Auth login") + const { token } = await useNuxtApp().$api("/auth/login", { + method: "POST", + body: { email, password } + }) + console.log(token) await this.fetchMe(token) }, async logout() { + console.log("Auth logout") try { await useNuxtApp().$api("/auth/logout", { method: "POST" }) } catch (e) { @@ -71,6 +98,7 @@ export const useAuthStore = defineStore("auth", { }, async fetchMe(jwt= null) { + console.log("Auth fetchMe") try { const me = await useNuxtApp().$api("/api/me", { headers: { Authorization: `Bearer ${jwt}`, @@ -92,7 +120,6 @@ export const useAuthStore = defineStore("auth", { if(me.activeTenant > 0) { this.activeTenant = me.activeTenant this.activeTenantData = me.tenants.find(i => i.id === me.activeTenant) - this.loading = false } else { @@ -105,6 +132,7 @@ export const useAuthStore = defineStore("auth", { }, async switchTenant(tenant_id: string) { + console.log("Auth switchTenant") this.loading = true const res = await useNuxtApp().$api("/api/tenant/switch", { method: "POST", @@ -124,11 +152,6 @@ export const useAuthStore = defineStore("auth", { } await this.init(token) - if(useCapacitor().getIsNative()) { - navigateTo("/mobile") - } else { - navigateTo("/") - } }, hasPermission(key: string) {