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
|
|
@ -6,12 +6,16 @@ off until the service has an OAuth client ID and secret.
|
|||
|
||||
## Who gets in
|
||||
|
||||
Two kinds of account can sign in with Google:
|
||||
Three kinds of account can sign in with Google:
|
||||
|
||||
- **Group accounts**, when access groups are set up (below): anyone in
|
||||
one of the site's Workspace groups. Their account is made at their
|
||||
first sign-in, and their role follows the group.
|
||||
- **Accounts made with admin-cli**, as before.
|
||||
- **Profile accounts** (members, `docs/profile-accounts.md`), invited
|
||||
from Data → Profile accounts. These are the one case outside the
|
||||
Workspace: any Google account under the invited email, from the
|
||||
site's `/sign-in` page or the invite's welcome page.
|
||||
|
||||
Created with
|
||||
`admin-cli.js add <email>` (the password it asks for stays as a way in
|
||||
|
|
@ -23,7 +27,8 @@ changes. `admin-cli.js list` shows which accounts are linked.
|
|||
Refused, with a message on the login page: no admin account for that
|
||||
email (and in no access group), an email already linked to a different Google account, a
|
||||
disabled account, any account outside the Workspace domain (checked by
|
||||
Google's `hd` claim, not just the email), an unverified email.
|
||||
Google's `hd` claim, not just the email) unless it's a profile account's,
|
||||
an unverified email.
|
||||
|
||||
Code: `server/src/googleAuth.js` (the Google side),
|
||||
`server/src/routes/auth.js` (matching and linking accounts) and
|
||||
|
|
|
|||
78
docs/profile-accounts.md
Normal file
78
docs/profile-accounts.md
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
# Profile accounts
|
||||
|
||||
People can have an account on the site for their own profile (migration
|
||||
076). Nobody signs up: an admin invites them.
|
||||
|
||||
## How it goes
|
||||
|
||||
1. **Invite.** Data → Profile accounts → Invite someone (admins and up):
|
||||
an email, and a name if you like. That makes a *member* account with
|
||||
no password, and shows its invite link once, for 14 days. Copy it to
|
||||
send yourself, or press Email invite to send a fresh one through
|
||||
Gmail (needs Gmail set up, `docs/google-drive-and-mail.md`; the link
|
||||
shown before stops working).
|
||||
2. **Sign up.** The link opens `/account/welcome`: they set a password,
|
||||
or continue with Google under the invited email (any Google account,
|
||||
not only @nextgenerationofunity.org, when Google sign-in is on,
|
||||
`docs/google-sign-in.md`). Either takes up the invite.
|
||||
3. **Claim.** On `/account` (Your profile, also the footer's Sign in
|
||||
link) they pick the People record that's them and send the request.
|
||||
It waits under Claims on Data → Profile accounts until an admin
|
||||
approves or declines it. An admin can also set an account's record
|
||||
directly there.
|
||||
4. **Edit.** With a record, they edit its pronouns, tagline, location,
|
||||
public email and phone, bio and photo, and tick what to hide on the
|
||||
site. Their name, publishing and everything else stay the admin's.
|
||||
Changes are live as soon as they save.
|
||||
|
||||
A member is below viewer: signed in to the site, never to the admin
|
||||
(`/api/admin` refuses anything under viewer, `requireStaff` in
|
||||
`server/src/auth.js`). Staff accounts can claim a record too, from
|
||||
`/account`.
|
||||
|
||||
Forgotten password: on the account's row, New sign-in link (or Email a
|
||||
sign-in link); opening it sets a new password.
|
||||
|
||||
Turn off stops an account signing in and ends its sessions. Remove
|
||||
deletes the account; its People record stays.
|
||||
|
||||
## What "hidden" does
|
||||
|
||||
Each hidden part (photo, pronouns, tagline, bio, public email, public
|
||||
phone, location, links) stays in the record, and the admin's People
|
||||
editor shows the same switches (Hidden on the site). The site never
|
||||
shows it: every public read goes through the `v_people_public` view,
|
||||
which nulls hidden fields, and person links are left out when links are
|
||||
hidden (`loadLinks` in `server/src/shape.js`). When adding a public
|
||||
query on people, read `v_people_public`, not `people`.
|
||||
|
||||
## Discord
|
||||
|
||||
A profile can link its Discord account (the `identify` scope only: the
|
||||
Discord user id and name), kept for the gamification to come. Off until
|
||||
the service has a Discord application:
|
||||
|
||||
1. https://discord.com/developers/applications → New Application.
|
||||
2. OAuth2 → Redirects: add `https://nextgenerationofunity.org/api/account/discord/callback`
|
||||
(and the dev server's address, if you test there).
|
||||
3. Copy the Client ID and Client Secret into the service's environment
|
||||
(`systemctl edit ngu-api`):
|
||||
|
||||
```
|
||||
[Service]
|
||||
Environment=DISCORD_CLIENT_ID=...
|
||||
Environment=DISCORD_CLIENT_SECRET=...
|
||||
```
|
||||
|
||||
`DISCORD_REDIRECT_URI` overrides the return address (default: site.json's
|
||||
`url` plus `/api/account/discord/callback`).
|
||||
4. `systemctl restart ngu-api`.
|
||||
|
||||
An admin can set or clear an account's Discord id by hand on its row
|
||||
(the long number from Discord: Developer Mode, then Copy User ID).
|
||||
|
||||
Code: `server/src/invites.js`, `server/src/discordAuth.js`,
|
||||
`server/src/routes/account.js` (the member's own routes),
|
||||
`server/src/routes/profiles.js` (the admin's), `src/pages/Account.tsx`,
|
||||
`src/pages/AccountWelcome.tsx`, `src/pages/SignIn.tsx`,
|
||||
`src/pages/admin/AdminProfiles.tsx`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue