Store Google profile picture bytes on google_auth
This commit is contained in:
12
README.md
12
README.md
@@ -71,17 +71,19 @@ For `PATCH /api/company/:id`:
|
||||
| Method | Signature | Returns |
|
||||
| --- | --- | --- |
|
||||
| `add` | `(email)` | `id` |
|
||||
| `getByEmail` | `(email)` | `{ id, email, picture, sub, createdAt, selectedCompanyId } \| undefined` |
|
||||
| `listAllowedEmails` | `()` | `{ id, email, picture, sub, createdAt, selectedCompanyId }[]` |
|
||||
| `getByEmail` | `(email)` | `{ id, email, picture, pictureBinary, sub, createdAt, selectedCompanyId } \| undefined` |
|
||||
| `getById` | `(googleAuthId)` | `{ id, email, picture, pictureBinary, sub, createdAt, selectedCompanyId } \| undefined` |
|
||||
| `listAllowedEmails` | `()` | `{ id, email, picture, sub, createdAt, selectedCompanyId }[]` (no `pictureBinary`) |
|
||||
| `removeAllowedEmail` | `(email)` | `void` |
|
||||
| `setSelectedCompany` | `(googleAuthId, companyId)` | `void` |
|
||||
| `setProfile` | `(googleAuthId, { picture?: string \| null, sub?: string \| null })` | `void` |
|
||||
| `setProfile` | `(googleAuthId, { picture?: string \| null, pictureBinary?: Buffer \| null, sub?: string \| null })` | `void` |
|
||||
|
||||
`picture` / `sub` come from the Google ID token (`payload.picture`, `payload.sub`). `sub` is Google’s stable subject id (unique when set). `setProfile` overwrites both columns (pass `null` to clear). Errors: `User not found`.
|
||||
`picture` is the Google profile image URL (kept for change detection / re-fetch). `picturebinary` stores the downloaded image bytes (`pictureBinary` in JS, `Buffer` from mssql). `sub` is Google’s stable subject id (unique when set). `setProfile` overwrites `picture`, `pictureBinary`, and `sub` (pass `null` to clear). Non-Buffer `pictureBinary` → `Invalid pictureBinary`. Errors: `User not found`.
|
||||
|
||||
Backend mapping:
|
||||
|
||||
- Login: `getByEmail(email)` then `setProfile(id, { picture, sub })` from the verified token
|
||||
- Login: `getByEmail(email)` then download `payload.picture` → `setProfile(id, { picture, pictureBinary, sub })`
|
||||
- `/auth/me`: `getById(googleAuthId)` → base64-encode `pictureBinary` for the response
|
||||
- CLI user manager: `listAllowedEmails()` / `removeAllowedEmail(email)` / `add(email)`
|
||||
- `PUT /api/auth/selected-company`: `setSelectedCompany(googleAuthId, companyId)`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user