u
This commit is contained in:
@@ -5,6 +5,7 @@ import JSZip from 'jszip';
|
||||
import * as db from '../../db/company.js';
|
||||
import * as googleAuth from '../../db/googleAuth.js';
|
||||
import { clearCachedUser } from '../middleware/auth.js';
|
||||
import { clearDeletedCompany, emit, setUserCompany } from '../sse.js';
|
||||
import { initCompanyVfs } from '../../tools/vfs.js';
|
||||
import { executeCompanyImport } from '../../services/companyImport.js';
|
||||
import { executeCompanyExport } from '../../services/companyExport.js';
|
||||
@@ -137,6 +138,7 @@ export function register(app, basePath = '') {
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* x-markdown: company/create.md
|
||||
* x-signals: [company]
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
@@ -215,6 +217,7 @@ export function register(app, basePath = '') {
|
||||
console.error('Failed to initialize company VFS:', vfsErr);
|
||||
}
|
||||
const authRow = await googleAuth.getAllowedEmail(req.user.email);
|
||||
setUserCompany(req.user.id, authRow.selectedCompanyId);
|
||||
res.status(201).json({ company, user: userPayload(authRow) });
|
||||
} catch (error) {
|
||||
const status = companyErrorStatus(error);
|
||||
@@ -834,6 +837,7 @@ export function register(app, basePath = '') {
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* x-markdown: company/update.md
|
||||
* x-signals: [company]
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
@@ -891,6 +895,7 @@ export function register(app, basePath = '') {
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* x-markdown: company/delete.md
|
||||
* x-signals: [company]
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
@@ -934,6 +939,7 @@ export function register(app, basePath = '') {
|
||||
|
||||
try {
|
||||
const company = await db.updateCompany(parsedId.companyId, body);
|
||||
emit('company', { companyId: parsedId.companyId, data: { companyId: parsedId.companyId } });
|
||||
res.status(200).json({ company });
|
||||
} catch (error) {
|
||||
const status = companyErrorStatus(error);
|
||||
@@ -954,6 +960,7 @@ export function register(app, basePath = '') {
|
||||
|
||||
try {
|
||||
await db.deleteCompany(parsedId.companyId);
|
||||
clearDeletedCompany(parsedId.companyId);
|
||||
res.sendStatus(204);
|
||||
} catch (error) {
|
||||
console.error('Delete company failed:', error);
|
||||
|
||||
Reference in New Issue
Block a user