From 20d8e40e4877d916a53c69c5d4318b6fad3398cf Mon Sep 17 00:00:00 2001 From: lelemm Date: Mon, 11 Nov 2024 10:06:31 -0300 Subject: [PATCH] Apply suggestions from code review Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- src/accounts/openid.js | 3 ++- src/app-sync.js | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/accounts/openid.js b/src/accounts/openid.js index 12948a850..c0d353f46 100644 --- a/src/accounts/openid.js +++ b/src/accounts/openid.js @@ -244,6 +244,7 @@ export async function loginWithOpenIdFinalize(body) { return { url: `${return_url}/openid-cb?token=${token}` }; } catch (err) { console.error('OpenID grant failed:', err); - return { error: 'openid-grant-failed: ' + err }; + console.error('OpenID grant failed:', err); + return { error: 'openid-grant-failed' }; } } diff --git a/src/app-sync.js b/src/app-sync.js index cd386bd55..260442207 100644 --- a/src/app-sync.js +++ b/src/app-sync.js @@ -246,7 +246,11 @@ app.post('/upload-user-file', async (req, res) => { syncVersion: syncFormatVersion, name: name, encryptMeta: encryptMeta, - owner: res.locals.user_id, + encryptMeta: encryptMeta, + // Ensure user_id exists before setting owner + owner: res.locals.user_id || (() => { + throw new Error('User ID is required for file creation'); + })(), }), );