feat(frontend): Add organization creation, deletion, add better-auth organization plugin
This commit is contained in:
39
legalconsenthub/stores/useUserStore.ts
Normal file
39
legalconsenthub/stores/useUserStore.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import type { FormSubmitEvent } from '@nuxt/ui'
|
||||
|
||||
export const useUserStore = defineStore('User', () => {
|
||||
const name = ref('')
|
||||
|
||||
async function signUp(payload: FormSubmitEvent<Schema>) {
|
||||
await authClient.signUp.email(
|
||||
{
|
||||
email: payload.data.email,
|
||||
password: payload.data.password,
|
||||
name: payload.data.name
|
||||
},
|
||||
{
|
||||
onRequest: (ctx) => {
|
||||
// TODO: Show loading spinner
|
||||
console.log('Sending register request')
|
||||
},
|
||||
onResponse: () => {
|
||||
// TODO: Hide loading spinner
|
||||
console.log('Receiving register response')
|
||||
},
|
||||
onSuccess: async (ctx) => {
|
||||
console.log('Successfully registered!')
|
||||
await navigateTo('/')
|
||||
},
|
||||
onError: (ctx) => {
|
||||
console.log(ctx.error.message)
|
||||
useToast().add({
|
||||
title: 'Fehler bei der Registrierung',
|
||||
description: ctx.error.message,
|
||||
color: 'success'
|
||||
})
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
return { name, signUp }
|
||||
})
|
||||
Reference in New Issue
Block a user