Fixed some Redirects for Mobile

Fixed other Login stuff on mobile
This commit is contained in:
2025-09-25 17:19:46 +02:00
parent 7f2a6ba438
commit 62c403307f
3 changed files with 27 additions and 6 deletions

View File

@@ -14,7 +14,11 @@ const doLogin = async (data:any) => {
await auth.login(data.email, data.password)
// Weiterleiten nach erfolgreichem Login
toast.add({title:"Einloggen erfolgreich"})
return navigateTo("/")
if(useCapacitor().getIsNative()) {
return navigateTo("/mobile")
} else {
return navigateTo("/")
}
} catch (err: any) {
toast.add({title:"Zugangsdaten falsch. Bitte überprüfen Sie Ihre Eingaben",color:"rose"})
}

View File

@@ -65,6 +65,14 @@ const auth = useAuthStore()
>
Objekte
</UButton>
<UButton
class="w-full my-1"
@click="auth.logout()"
color="rose"
variant="outline"
>
Abmelden
</UButton>
<UDivider class="my-5">Unternehmen wechseln</UDivider>

View File

@@ -16,7 +16,12 @@ export const useAuthStore = defineStore("auth", {
actions: {
async init(token) {
await this.fetchMe(token)
navigateTo("/")
if(useCapacitor().getIsNative()) {
navigateTo("/mobile")
} else {
navigateTo("/")
}
},
async login(email: string, password: string) {
@@ -24,7 +29,7 @@ export const useAuthStore = defineStore("auth", {
method: "POST",
body: { email, password }
})
if(await useCapacitor().getIsNative()) {
if(useCapacitor().getIsNative()) {
await Preferences.set({
key:"token",
value: token,
@@ -49,7 +54,7 @@ export const useAuthStore = defineStore("auth", {
this.tenants = []
if(useCapacitor().getIsNative()) {
await Preferences.remove({ key: 'token' });
useCookie("token").value = null
} else {
useCookie("token").value = null
}
@@ -77,7 +82,7 @@ export const useAuthStore = defineStore("auth", {
this.profile = me.profile
if(me.activeTenant) {
if(me.activeTenant > 0) {
this.activeTenant = me.activeTenant
this.activeTenantData = me.tenants.find(i => i.id === me.activeTenant)
this.loading = false
@@ -112,7 +117,11 @@ export const useAuthStore = defineStore("auth", {
}
await this.init(token)
navigateTo("/")
if(useCapacitor().getIsNative()) {
navigateTo("/mobile")
} else {
navigateTo("/")
}
},
hasPermission(key: string) {