Store Google profile picture bytes on google_auth
This commit is contained in:
12
src/store/google_auth/getById.js
Normal file
12
src/store/google_auth/getById.js
Normal 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];
|
||||
};
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user