This commit is contained in:
seb
2026-10-06 05:19:16 +02:00
parent fe5990af9f
commit 1be561376e
6 changed files with 151 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
import * as db from '../../db/company.js';
import * as googleAuth from '../../db/googleAuth.js';
import { clearCachedUser } from '../middleware/auth.js';
import { initCompanyVfs } from '../../tools/vfs.js';
function userPayload(authRow) {
return {
@@ -169,6 +170,11 @@ export function register(app, basePath = '') {
const company = await db.createCompany(req.user.id, body);
await googleAuth.setSelectedCompany(req.user.id, company.id);
clearCachedUser(req.user.id);
try {
await initCompanyVfs({ googleAuthId: req.user.id });
} catch (vfsErr) {
console.error('Failed to initialize company VFS:', vfsErr);
}
const authRow = await googleAuth.getAllowedEmail(req.user.email);
res.status(201).json({ company, user: userPayload(authRow) });
} catch (error) {