u
This commit is contained in:
@@ -3,6 +3,7 @@ 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 * as companyDb from '../../../db/company.js';
|
||||
import { clearCachedUser } from '../../middleware/auth.js';
|
||||
import { downloadPicture, toPictureBuffer } from '../../../util/pictureBinary.js';
|
||||
|
||||
@@ -109,6 +110,13 @@ export function register(app, basePath = '') {
|
||||
if (!allowed && (env.implicitCreate || (await autoinviteDb.hasPendingInvite(email)))) {
|
||||
await db.addAllowedEmail(email);
|
||||
allowed = await db.getAllowedEmail(email);
|
||||
if (allowed && allowed.selectedCompanyId == null) {
|
||||
const companies = await companyDb.listCompanies(allowed.id);
|
||||
if (companies.length > 0) {
|
||||
await db.setSelectedCompany(allowed.id, companies[0].id);
|
||||
allowed = await db.getAllowedEmail(email);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!allowed) {
|
||||
console.warn(`Login rejected: email not authorized (${email})`);
|
||||
|
||||
Reference in New Issue
Block a user