u
This commit is contained in:
@@ -2,6 +2,7 @@ import jwt from 'jsonwebtoken';
|
||||
import { OAuth2Client } from 'google-auth-library';
|
||||
import env from '../../../config/env.js';
|
||||
import * as db from '../../../db/googleAuth.js';
|
||||
import * as autoinviteDb from '../../../db/autoinvite.js';
|
||||
import { clearCachedUser } from '../../middleware/auth.js';
|
||||
import { downloadPicture, toPictureBuffer } from '../../../util/pictureBinary.js';
|
||||
|
||||
@@ -20,7 +21,8 @@ export function register(app, basePath = '') {
|
||||
* tags: [Auth]
|
||||
* summary: Login with Google ID token
|
||||
* description: |
|
||||
* Verifies a Google ID token, checks allowlist (or creates entry when `IMPLICIT_CREATE=true`),
|
||||
* Verifies a Google ID token, checks allowlist (or creates entry when `IMPLICIT_CREATE=true`
|
||||
* or when the email has a pending auto-invitation),
|
||||
* stores Google `sub` and profile image bytes, and sets an HTTP-only `token` cookie.
|
||||
* `user.picture` is the profile image as base64 (same as GET /auth/me).
|
||||
* security: []
|
||||
@@ -64,7 +66,7 @@ export function register(app, basePath = '') {
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
* 403:
|
||||
* description: Email not on allowlist
|
||||
* description: Email not on allowlist or invited
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
@@ -104,7 +106,7 @@ export function register(app, basePath = '') {
|
||||
}
|
||||
|
||||
let allowed = await db.getAllowedEmail(email);
|
||||
if (!allowed && env.implicitCreate) {
|
||||
if (!allowed && (env.implicitCreate || (await autoinviteDb.hasPendingInvite(email)))) {
|
||||
await db.addAllowedEmail(email);
|
||||
allowed = await db.getAllowedEmail(email);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user