Files
faunosteo/packages/supabase/src/platform-roles.ts
T
bchanot b10b227ee9 feat(supabase): auth, profile and roles services; professional columns on profiles; OAuth + TOTP config
- packages/supabase: signIn/signUp/OAuth/reset/updatePassword/signOut wrappers with a closed AuthFailure kind, fetch/update own profile, own platform roles
- migration 20261011100000: practice_name, professional_title, siret (format-checked, column grants); pgTAP 009; database.types regenerated
- config.toml: TOTP enroll/verify on, [auth.external.google|apple] via env(), wildcard redirect URLs
- app config: authProviders (APP_AUTH_PROVIDERS / VITE_AUTH_PROVIDERS), entrypoint env.js, DEPLOY table
- TODO: Step 7 plan
2026-10-11 23:16:13 +02:00

19 lines
592 B
TypeScript

import type { FaunosteoClient } from './client'
import type { Enums } from './database.types'
export type PlatformRole = Enums<'platform_role'>
/** Active platform roles of the signed-in user (RLS: own rows, or any as admin). */
export async function fetchOwnPlatformRoles(
client: FaunosteoClient,
userId: string,
): Promise<PlatformRole[]> {
const { data, error } = await client
.from('profile_roles')
.select('role')
.eq('user_id', userId)
.is('revoked_at', null)
if (error) throw new Error(error.message, { cause: error })
return data.map((row) => row.role)
}