Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
lelemm and coderabbitai[bot] authored Nov 11, 2024
1 parent b33da56 commit e49e391
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/accounts/openid.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function bootstrapOpenId(config) {
}

let accountDb = getAccountDb();
//accountDb.transaction(() => {
accountDb.transaction(() => {
accountDb.mutate('DELETE FROM auth WHERE method = ?', ['openid']);

Check failure on line 34 in src/accounts/openid.js

View workflow job for this annotation

GitHub Actions / lint

Insert `··`
accountDb.mutate('UPDATE auth SET active = 0');

Check failure on line 35 in src/accounts/openid.js

View workflow job for this annotation

GitHub Actions / lint

Insert `··`
accountDb.mutate(

Check failure on line 36 in src/accounts/openid.js

View workflow job for this annotation

GitHub Actions / lint

Insert `··`
Expand All @@ -39,7 +39,7 @@ export async function bootstrapOpenId(config) {
);

Check failure on line 39 in src/accounts/openid.js

View workflow job for this annotation

GitHub Actions / lint

Insert `··`

console.log(accountDb.all('select * from auth'));

Check failure on line 41 in src/accounts/openid.js

View workflow job for this annotation

GitHub Actions / lint

Insert `··`
//});
});

console.log(accountDb.all('select * from auth'));

Expand Down Expand Up @@ -83,7 +83,8 @@ export async function loginWithOpenIdSetup(body) {
try {
config = JSON.parse(config['extra_data']);
} catch (err) {
return { error: 'openid-setup-failed: ' + err };
console.error('Error parsing OpenID configuration:', err);
return { error: 'openid-setup-failed' };
}

let client;
Expand Down Expand Up @@ -138,13 +139,15 @@ export async function loginWithOpenIdFinalize(body) {
try {
config = JSON.parse(config['extra_data']);
} catch (err) {
return { error: 'openid-setup-failed: ' + err };
console.error('Error parsing OpenID configuration:', err);
return { error: 'openid-setup-failed' };
}
let client;
try {
client = await setupOpenIdClient(config);
} catch (err) {
return { error: 'openid-setup-failed: ' + err };
console.error('Error setting up OpenID client:', err);
return { error: 'openid-setup-failed' };
}

let pendingRequest = accountDb.first(
Expand All @@ -159,12 +162,8 @@ export async function loginWithOpenIdFinalize(body) {
let { code_verifier, return_url } = pendingRequest;

try {
let grant = await client.grant({
grant_type: 'authorization_code',
code: body.code,
code_verifier,
redirect_uri: client.redirect_uris[0],
});
const params = { code: body.code, state: body.state };
let tokenSet = await client.callback(client.redirect_uris[0], params, { code_verifier });

Check failure on line 166 in src/accounts/openid.js

View workflow job for this annotation

GitHub Actions / lint

'tokenSet' is assigned a value but never used

Check failure on line 166 in src/accounts/openid.js

View workflow job for this annotation

GitHub Actions / lint

Replace `·code_verifier` with `⏎······code_verifier,⏎···`
const userInfo = await client.userinfo(grant);

Check failure on line 167 in src/accounts/openid.js

View workflow job for this annotation

GitHub Actions / lint

'grant' is not defined

Check failure on line 167 in src/accounts/openid.js

View workflow job for this annotation

GitHub Actions / build

Cannot find name 'grant'.
const identity =
userInfo.preferred_username ??
Expand Down

0 comments on commit e49e391

Please sign in to comment.