This commit is contained in:
seb
2026-10-09 10:43:56 +02:00
parent 011d84c3c1
commit 728b3ec172
3 changed files with 35 additions and 35 deletions

View File

@@ -1,4 +1,4 @@
import { meJson } from '../../auth/meJson.js';
import { respondWithAuthenticatedUser } from '../../auth/meJson.js';
import * as db from '../../../db/googleAuth.js';
import { toPictureBuffer } from '../../../util/pictureBinary.js';
@@ -49,7 +49,7 @@ export function register(app, basePath = '') {
try {
const row = await db.getById(req.user.id);
if (!row) {
return meJson(res, 403, { error: 'User is no longer authorized' });
return respondWithAuthenticatedUser(res, 403, { error: 'User is no longer authorized' });
}
const pictureBinary = toPictureBuffer(row.pictureBinary);
@@ -59,10 +59,10 @@ export function register(app, basePath = '') {
selectedCompanyId: row.selectedCompanyId,
...(pictureBinary && { picture: pictureBinary.toString('base64') }),
};
meJson(res, 200, { user });
respondWithAuthenticatedUser(res, 200, { user });
} catch (error) {
console.error('Get current user failed:', error);
meJson(res, 500, { error: 'Failed to load user' });
respondWithAuthenticatedUser(res, 500, { error: 'Failed to load user' });
}
});
}