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