Profile accounts: invites, any-Google sign-in, claiming People, visibility, Discord
Migration 076 adds a member role below viewer (the site and its own profile, never the admin: /api/admin now needs viewer), invites, person claims, a Discord link on accounts and people.hide_* switches. Public reads of people go through v_people_public, which nulls hidden fields, and the views that read people are rebuilt over it. Admins invite an email from Data -> Profile accounts (link shown once, emailed on request). The invitee sets a password or signs in with any Google account under that email, asks to claim their People record, and once approved edits it and chooses what shows at /account. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0cc2a3f721
commit
e4c7e165d1
34 changed files with 2483 additions and 74 deletions
44
src/lib/useAccount.ts
Normal file
44
src/lib/useAccount.ts
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/* A profile account's own page (server/src/routes/account.js): the
|
||||
account, the People record it has (as its owner edits it), its
|
||||
claim, and Discord. Not cached: it changes as they edit it. */
|
||||
|
||||
import { useRecord, type Resource } from './useRecord.ts'
|
||||
|
||||
/* What an owner can take off the site (people.hide_*), in the order
|
||||
the profile page lists them. */
|
||||
export const HIDE_FIELDS = [
|
||||
['photo', 'Photo'],
|
||||
['pronouns', 'Pronouns'],
|
||||
['tagline', 'Tagline'],
|
||||
['bio', 'Bio'],
|
||||
['email', 'Public email'],
|
||||
['phone', 'Public phone'],
|
||||
['location', 'Location'],
|
||||
['links', 'Links'],
|
||||
] as const
|
||||
|
||||
export type HideField = (typeof HIDE_FIELDS)[number][0]
|
||||
|
||||
export type MyPerson = {
|
||||
id: string
|
||||
display_name: string
|
||||
is_published: boolean
|
||||
photo: string | null
|
||||
pronouns: string | null
|
||||
tagline: string | null
|
||||
bio: string | null
|
||||
public_email: string | null
|
||||
public_phone: string | null
|
||||
location_label: string | null
|
||||
hidden: Record<HideField, boolean>
|
||||
}
|
||||
|
||||
export type MyAccount = {
|
||||
user: { id: number; email: string; name: string | null; role: string }
|
||||
person: MyPerson | null
|
||||
claim: { id: number; person_id: string; display_name: string; status: 'pending' | 'approved' | 'declined' } | null
|
||||
discord: { enabled: boolean; id: string | null; name: string | null }
|
||||
}
|
||||
|
||||
export const useMyAccount = (enabled: boolean): Resource<MyAccount> =>
|
||||
useRecord(enabled ? '/account' : null, 'account')
|
||||
Loading…
Add table
Add a link
Reference in a new issue