fix(portal): add invitation links and correct customer login routing
All checks were successful
Build and Release FEDEO / verify (push) Successful in 1m7s
Build and Release FEDEO / build-and-release (push) Successful in 6m24s

This commit is contained in:
2026-10-13 18:13:41 +02:00
parent 070be08207
commit 5463106938
10 changed files with 302 additions and 29 deletions

View File

@@ -31,6 +31,11 @@ export const useAuthStore = defineStore("auth", {
}),
actions: {
getLandingPath() {
if (this.user?.must_change_password) return "/password-change"
return this.profile?.customer_for_portal ? "/customer-portal" : "/"
},
tokenCookie() {
return useCookie<string | null>("token", { path: "/" })
},
@@ -265,14 +270,14 @@ export const useAuthStore = defineStore("auth", {
const tempStore = useTempStore()
if(this.profile?.temp_config) tempStore.setStoredTempConfig(this.profile.temp_config)
this.loading = false
if(this.activeTenant > 0) {
this.loading = false
navigateTo("/")
return navigateTo(this.getLandingPath())
}
},
async login(email: string, password: string, rememberMe = false) {
this.loading = true
try {
console.log("Auth login")
const { token, refreshToken } = await useNuxtApp().$api("/auth/login", {
@@ -289,21 +294,15 @@ export const useAuthStore = defineStore("auth", {
await this.fetchMe(token)
// 3. WICHTIG: Jetzt explizit weiterleiten!
// Prüfen, ob der User geladen wurde
if (this.user) {
// Falls Passwort-Änderung erzwungen wird (passend zu deiner Middleware)
if (this.user.must_change_password) {
return navigateTo("/password-change")
}
// Normaler Login -> Dashboard
return navigateTo("/")
}
if (!this.user) throw new Error("Die Sitzung konnte nicht geladen werden.")
this.loading = false
return await navigateTo(this.getLandingPath(), { replace: true })
} catch (e) {
console.log("login error:" + e)
throw e
} finally {
this.loading = false
}
},