New Backend changes

This commit is contained in:
2025-08-31 18:28:59 +02:00
parent b0497142ed
commit 6d76acc0bc
26 changed files with 813 additions and 1379 deletions

View File

@@ -1,5 +1,5 @@
<template>
<UDashboardNavbar title="Home">
<!-- <UDashboardNavbar title="Home">
<template #right>
<UTooltip text="Notifications" :shortcuts="['N']">
<UButton color="gray" variant="ghost" square @click="isNotificationsSlideoverOpen = true">
@@ -59,16 +59,14 @@
<display-open-tasks/>
</UDashboardCard>
</UPageGrid>
</UDashboardPanelContent>
</UDashboardPanelContent>-->
</template>
<script setup>
import DisplayPresentProfiles from "~/components/noAutoLoad/displayPresentProfiles.vue";
definePageMeta({
middleware: ["auth","redirect-to-mobile-index"]
})
const dataStore = useDataStore()
const profileStore = useProfileStore()
@@ -76,24 +74,14 @@ const toast = useToast()
const router = useRouter()
const { isNotificationsSlideoverOpen } = useDashboard()
const items = [[{
label: 'Aufgabe',
icon: 'i-heroicons-paper-airplane',
to: '/tasks/create'
}, {
label: 'Kunde',
icon: 'i-heroicons-user-plus',
to: '/customers/create'
}]]
const supabase = useSupabaseClient()
const user = useSupabaseUser()
const unreadMessages = ref(false)
const setup = async () => {
unreadMessages.value = (await supabase.from("notifications").select("id,read").eq("read",false)).data.length > 0
}
setup()

View File

@@ -1,118 +1,32 @@
<script setup >
import {useProfileStore} from "~/stores/profile.js";
import {useCapacitor} from "~/composables/useCapacitor.js";
<script setup lang="ts">
definePageMeta({
layout: "notLoggedIn"
})
const supabase = useSupabaseClient()
const user = useSupabaseUser()
const router = useRouter()
const colorMode = useColorMode()
const auth = useAuthStore()
const toast = useToast()
const profileStore = useProfileStore()
const isLight = computed({
get () {
return colorMode.value !== 'dark'
},
set () {
colorMode.preference = colorMode.value === 'dark' ? 'light' : 'dark'
}
})
const email = ref("")
const password = ref("")
const fields = [{
name: 'email',
type: 'text',
label: 'Email',
placeholder: 'E-Mail Adresse'
}, {
name: 'password',
label: 'Password',
type: 'password',
placeholder: 'Passwort'
}]
const authenticateWithAzure = async () => {
const { data, error } = await supabase.auth.signInWithOAuth({
provider: 'azure',
options: {
scopes: 'email',
},
})
console.log(data)
console.log(error)
}
const onSubmit = async (data) => {
const {error, data:{ user}} = await supabase.auth.signInWithPassword({
email: data.email,
password: data.password
})
if(error) {
if(error.toString().toLowerCase().includes("invalid")){
toast.add({title:"Zugangsdaten falsch",color:"rose"})
}
} else {
//console.log("Login Successful")
profileStore.initializeData(user.id)
if(await useCapacitor().getIsPhone()) {
router.push("/mobile")
} else {
router.push("/")
}
const doLogin = async (data:any) => {
try {
await auth.login(data.email, data.password)
// Weiterleiten nach erfolgreichem Login
toast.add({title:"Einloggen erfolgreich"})
return navigateTo("/")
} catch (err: any) {
toast.add({title:"Zugangsdaten falsch. Bitte überprüfen Sie Ihre Eingaben",color:"rose"})
}
}
</script>
<template>
<!-- <div id="loginSite">
<div id="loginForm">
<UFormGroup
label="E-Mail:"
>
<UInput
v-model="email"
/>
</UFormGroup>
<UFormGroup
label="Passwort:"
>
<UInput
v-model="password"
type="password"
@keyup.enter="onSubmit"
/>
</UFormGroup>
<UButton
@click="onSubmit"
class="mt-3"
>
Einloggen
</UButton>
</div>
</div>-->
<UCard class="max-w-sm w-full mx-auto mt-5">
<UColorModeImage
light="/Logo.png"
dark="/Logo_Dark.png"
light="/Logo.png"
dark="/Logo_Dark.png"
/>
<UAuthForm
@@ -131,29 +45,13 @@ const onSubmit = async (data) => {
placeholder: 'Dein Passwort'
}]"
:loading="false"
@submit="onSubmit"
:providers="[{label: 'MS365',icon: 'i-simple-icons-microsoft',color: 'gray',click: authenticateWithAzure}]"
@submit="doLogin"
:submit-button="{label: 'Weiter'}"
divider="oder"
>
<template #password-hint>
<NuxtLink to="/password-reset" class="text-primary font-medium">Passwort vergessen?</NuxtLink>
</template>
</UAuthForm>
</UCard>
</template>
<style scoped>
#loginSite {
display: flex;
align-content: center;
justify-content: center;
}
#loginForm {
width: 30vw;
height: 30vh;
}
</style>
</template>

62
pages/password-change.vue Normal file
View File

@@ -0,0 +1,62 @@
<script setup lang="ts">
definePageMeta({
layout: "notLoggedIn"
})
const auth = useAuthStore()
const toast = useToast()
const doChange = async (data:any) => {
try {
const res = await useNuxtApp().$api("/api/auth/password/change", {
method: "POST",
body: {
old_password: data.oldPassword,
new_password: data.newPassword,
}
})
// Weiterleiten nach erfolgreichem Login
toast.add({title:"Ändern erfolgreich"})
await auth.logout()
return navigateTo("/login")
} catch (err: any) {
toast.add({title:"Es gab ein Problem beim ändern",color:"rose"})
}
}
</script>
<template>
<UCard class="max-w-sm w-full mx-auto mt-5">
<UColorModeImage
light="/Logo.png"
dark="/Logo_Dark.png"
/>
<UAuthForm
title="Passwort zurücksetzen"
description="Geben Sie Ihre E-Mail ein um ein neues Passwort per E-Mail zu erhalten."
align="bottom"
:fields="[{
name: 'oldPassword',
label: 'Altes Passwort',
type: 'password',
placeholder: 'Dein altes Passwort'
},{
name: 'newPassword',
label: 'Neues Passwort',
type: 'password',
placeholder: 'Dein neues Passwort'
}]"
:loading="false"
@submit="doChange"
:submit-button="{label: 'Ändern'}"
divider="oder"
>
</UAuthForm>
</UCard>
</template>

55
pages/password-reset.vue Normal file
View File

@@ -0,0 +1,55 @@
<script setup lang="ts">
definePageMeta({
layout: "notLoggedIn"
})
const auth = useAuthStore()
const toast = useToast()
const doReset = async (data:any) => {
try {
const res = await useNuxtApp().$api("/auth/password/reset", {
method: "POST",
body: {
email: data.email
}
})
// Weiterleiten nach erfolgreichem Login
toast.add({title:"Zurücksetzen erfolgreich"})
return navigateTo("/login")
} catch (err: any) {
toast.add({title:"Problem beim zurücksetzen",color:"rose"})
}
}
</script>
<template>
<UCard class="max-w-sm w-full mx-auto mt-5">
<UColorModeImage
light="/Logo.png"
dark="/Logo_Dark.png"
/>
<UAuthForm
title="Passwort zurücksetzen"
description="Geben Sie Ihre E-Mail ein um ein neues Passwort per E-Mail zu erhalten."
align="bottom"
:fields="[{
name: 'email',
type: 'text',
label: 'Email',
placeholder: 'Deine E-Mail Adresse'
}]"
:loading="false"
@submit="doReset"
:submit-button="{label: 'Zurücksetzen'}"
divider="oder"
>
</UAuthForm>
</UCard>
</template>

View File

@@ -3,12 +3,12 @@ import {setPageLayout} from "#app";
import {useCapacitor} from "~/composables/useCapacitor.js";
definePageMeta({
middleware: "auth",
layout: "default",
})
const route = useRoute()
const dataStore = useDataStore()
const supabase = useSupabaseClient()
const api = useNuxtApp().$api
const type = route.params.type
const platform = await useCapacitor().getIsPhone() ? "mobile" : "default"
@@ -32,12 +32,14 @@ const setupPage = async () => {
if(mode.value === "show") {
//Load Data for Show
item.value = await useSupabaseSelectSingle(type, route.params.id, dataType.supabaseSelectWithInformation || "*")
//item.value = await useSupabaseSelectSingle(type, route.params.id, dataType.supabaseSelectWithInformation || "*")
item.value = await useEntities(type).selectSingle(route.params.id,"*",true)
} else if(mode.value === "edit") {
//Load Data for Edit
const data = JSON.stringify((await supabase.from(type).select().eq("id", route.params.id).single()).data)
//const data = JSON.stringify((await supabase.from(type).select().eq("id", route.params.id).single()).data)
//await useSupabaseSelectSingle(type, route.params.id)
item.value = data
item.value = JSON.stringify(await useEntities(type).selectSingle(route.params.id))
//item.value = data
} else if(mode.value === "create") {
//Load Data for Create
@@ -46,7 +48,7 @@ const setupPage = async () => {
console.log(item.value)
} else if(mode.value === "list") {
//Load Data for List
items.value = await useSupabaseSelect(type, dataType.supabaseSelectWithInformation || "*", dataType.supabaseSortColumn,dataType.supabaseSortAscending || false, true)
items.value = await useEntities(type).select()
}
loaded.value = true