This commit is contained in:
Omer Sabic 2024-06-07 22:23:30 +02:00
parent 34fe0dc034
commit ab00a416e8

View File

@ -28,8 +28,10 @@ export const authRoutes = (fastify, _, done) => {
const channel_info = await getChannelInfo(token.access_token); const channel_info = await getChannelInfo(token.access_token);
const [existing_user] = await db.select().from(usersTable).where(eq(usersTable.google_id, user_info.id)); const [existing_user] = await db.select().from(usersTable).where(eq(usersTable.google_id, user_info.id));
console.log("existing user", existing_user);
let user; let user;
let session_id; let session_id;
let errorCode;
await db.transaction(async tx => { await db.transaction(async tx => {
try { try {
if (existing_user) { if (existing_user) {
@ -85,6 +87,7 @@ export const authRoutes = (fastify, _, done) => {
} }
} catch (e) { } catch (e) {
console.log(e); console.log(e);
errorCode = e.message;
await tx.rollback(); await tx.rollback();
return; return;
} }
@ -109,7 +112,7 @@ export const authRoutes = (fastify, _, done) => {
response.status(400).send("Your account does not have a youtube channel. Please make one.") response.status(400).send("Your account does not have a youtube channel. Please make one.")
} }
console.log(e); console.log(e);
response.send({ success: false, message: e.message }); response.send({ success: false, message: "There was a problem when making your account.", ...(errorCode ? {debug: errorCode} : "") });
return; return;
} }
}); });