feat(fullstack): Add notifications, user is now an entity, add testcontainers, rework custom permissions, get user from JWT in endpoints

This commit is contained in:
2025-08-09 10:09:00 +02:00
parent a5eae07eaf
commit 7e55a336f2
44 changed files with 1571 additions and 139 deletions

View File

@@ -20,6 +20,7 @@
<script setup lang="ts">
import * as z from 'zod'
import type { FormSubmitEvent } from '@nuxt/ui'
import { UserRole } from '~/.api-client'
definePageMeta({ layout: 'auth' })
@@ -27,6 +28,7 @@ useSeoMeta({ title: 'Sign up' })
const toast = useToast()
const { signUp } = useAuth()
const { createUser } = useUser()
const fields = [
{
@@ -90,8 +92,28 @@ function onSubmit(payload: FormSubmitEvent<Schema>) {
// TODO: Hide loading spinner
console.log('Receiving register response')
},
onSuccess: async () => {
onSuccess: async (ctx) => {
console.log('Successfully registered!')
// Create user in backend after successful Better Auth registration
try {
console.log('Creating user in backend...', ctx.data)
await createUser({
id: ctx.data.user.id,
name: ctx.data.user.name,
status: 'ACTIVE',
role: UserRole.Employee
})
console.log('User created in backend successfully')
} catch (error) {
console.error('Failed to create user in backend:', error)
toast.add({
title: 'Warning',
description: 'Account created but there was an issue with backend setup. Please contact support.',
color: 'warning'
})
}
await navigateTo('/')
},
onError: (ctx) => {