feat(release): prepare 1.1.0 candidate
This commit is contained in:
parent
5a34f66981
commit
5205dcdfa9
736 changed files with 115667 additions and 12203 deletions
44
apps/mobile-rn/src/lib/auth-capabilities.ts
Normal file
44
apps/mobile-rn/src/lib/auth-capabilities.ts
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
import { SUPABASE_ANON_KEY, SUPABASE_URL } from '@d3ro/core/supabase-config'
|
||||
|
||||
export interface AuthCapabilities {
|
||||
signUpEnabled: boolean
|
||||
emailEnabled: boolean
|
||||
googleEnabled: boolean
|
||||
githubEnabled: boolean
|
||||
appleEnabled: boolean
|
||||
}
|
||||
|
||||
interface AuthSettingsResponse {
|
||||
disable_signup?: boolean
|
||||
external?: {
|
||||
email?: boolean
|
||||
google?: boolean
|
||||
github?: boolean
|
||||
apple?: boolean
|
||||
}
|
||||
}
|
||||
|
||||
let cachedCapabilities: AuthCapabilities | null = null
|
||||
|
||||
export async function getAuthCapabilities(forceRefresh = false): Promise<AuthCapabilities> {
|
||||
if (!forceRefresh && cachedCapabilities !== null) return cachedCapabilities
|
||||
|
||||
const response = await fetch(`${SUPABASE_URL}/auth/v1/settings`, {
|
||||
headers: { apikey: SUPABASE_ANON_KEY },
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Auth settings request failed with status ${response.status}`)
|
||||
}
|
||||
|
||||
const settings = await response.json() as AuthSettingsResponse
|
||||
const external = settings.external ?? {}
|
||||
cachedCapabilities = {
|
||||
signUpEnabled: settings.disable_signup !== true,
|
||||
emailEnabled: external.email === true,
|
||||
googleEnabled: external.google === true,
|
||||
githubEnabled: external.github === true,
|
||||
appleEnabled: external.apple === true,
|
||||
}
|
||||
return cachedCapabilities
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue