| 1 | import { apiKeyClient } from '@better-auth/api-key/client' |
| 2 | import { |
| 3 | inferAdditionalFields, |
| 4 | lastLoginMethodClient, |
| 5 | organizationClient, |
| 6 | } from 'better-auth/client/plugins' |
| 7 | import { createAuthClient } |
| 8 | import { toast } |
| 9 | |
| 10 | import type { auth |
| 11 | import { |
| 12 | ac, |
| 13 | adminRole, |
| 14 | clientRole, |
| 15 | memberRole, |
| 16 | ownerRole, |
| 17 | } from '@/server/auth/permissions' |
| 18 | // import { env } from '@/env' |
| 19 | |
| 20 | export const authClient = |
| 21 | plugins: [ |
| 22 | inferAdditionalFields<typeof auth |
| 23 | apiKeyClient(), |
| 24 | lastLoginMethodClient(), |
| 25 | organizationClient({ |
| 26 | teams: { enabled: true |
| 27 | ac, |
| 28 | roles: { |
| 29 | owner: ownerRole, |
| 30 | admin: adminRole, |
| 31 | member: memberRole, |
| 32 | client: clientRole, |
| 33 | }, |
| 34 | }), |
| 35 | ], |
| 36 | // baseURL: env.NEXT_PUBLIC_BASE_URL, |
| 37 | fetchOptions: { |
| 38 | onError(e) { |
| 39 | if (e.error |
| 40 | toast.error('Too many requests. Please try again later. |
| 41 | } |
| 42 | }, |
| 43 | }, |
| 44 | }) |
| 45 | |
| 46 | export const signIn: |
| 47 | export const signOut: |
| 48 | export const useSession: |
| 49 | |
| 50 | export type User |