feat(frontend): Use betterAuth implementation from nuxthub-better-auth project
This commit is contained in:
@@ -3,6 +3,7 @@ const selectedOrgId = ref<string | undefined>(undefined)
|
||||
|
||||
export function useBetterAuth() {
|
||||
const toast = useToast()
|
||||
const { organization } = useAuth()
|
||||
|
||||
async function createOrganization(name: string, slug: string, logo?: string) {
|
||||
await organization.create(
|
||||
@@ -25,7 +26,7 @@ export function useBetterAuth() {
|
||||
}
|
||||
|
||||
async function deleteOrganization() {
|
||||
await authClient.organization.delete(
|
||||
await organization.delete(
|
||||
{ organizationId: activeOrganization.value?.id ?? '' },
|
||||
{
|
||||
onSuccess: () => {
|
||||
@@ -41,7 +42,7 @@ export function useBetterAuth() {
|
||||
}
|
||||
|
||||
async function getInvitation(invitationId: string): Promise<CustomInvitation> {
|
||||
return authClient.organization.getInvitation({
|
||||
return organization.getInvitation({
|
||||
query: { id: invitationId },
|
||||
fetchOptions: {
|
||||
throw: true,
|
||||
@@ -56,7 +57,7 @@ export function useBetterAuth() {
|
||||
}
|
||||
|
||||
async function inviteMember(email: string, role: 'member' | 'admin') {
|
||||
await authClient.organization.inviteMember({
|
||||
await organization.inviteMember({
|
||||
email,
|
||||
role,
|
||||
fetchOptions: {
|
||||
@@ -77,7 +78,7 @@ export function useBetterAuth() {
|
||||
}
|
||||
|
||||
async function acceptInvitation(invitationId: string) {
|
||||
await authClient.organization.acceptInvitation({
|
||||
await organization.acceptInvitation({
|
||||
invitationId,
|
||||
fetchOptions: {
|
||||
throw: true,
|
||||
@@ -93,7 +94,7 @@ export function useBetterAuth() {
|
||||
}
|
||||
|
||||
async function rejectInvitation(invitationId: string) {
|
||||
await authClient.organization.rejectInvitation({
|
||||
await organization.rejectInvitation({
|
||||
invitationId,
|
||||
fetchOptions: {
|
||||
throw: true,
|
||||
|
||||
Reference in New Issue
Block a user