Store Google profile picture bytes on google_auth

This commit is contained in:
seb
2026-08-05 11:08:06 +02:00
parent d1eb2716ae
commit 561ba5bb99
9 changed files with 859 additions and 812 deletions

View File

@@ -0,0 +1,12 @@
import { GET_BY_ID } from '../../sql/google_auth.js';
export default function getById(pool) {
return async (googleAuthId) => {
const result = await pool
.request()
.input('googleAuthId', googleAuthId)
.query(GET_BY_ID);
return result.recordset[0];
};
}

View File

@@ -1,11 +1,19 @@
import { SET_PROFILE } from '../../sql/google_auth.js';
export default function setProfile(pool) {
return async (googleAuthId, { picture = null, sub = null } = {}) => {
return async (
googleAuthId,
{ picture = null, pictureBinary = null, sub = null } = {},
) => {
if (pictureBinary != null && !Buffer.isBuffer(pictureBinary)) {
throw new Error('Invalid pictureBinary');
}
const result = await pool
.request()
.input('googleAuthId', googleAuthId)
.input('picture', picture)
.input('pictureBinary', pictureBinary)
.input('sub', sub)
.query(SET_PROFILE);