Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
lelemm committed Dec 20, 2024
1 parent 2ec5b1c commit f516740
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
22 changes: 19 additions & 3 deletions src/account-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,25 @@ export async function disableOpenID(loginSettings) {
return { error };
}

getAccountDb().mutate('DELETE FROM sessions');
getAccountDb().mutate('DELETE FROM users WHERE user_name <> ?', ['']);
getAccountDb().mutate('DELETE FROM auth WHERE method = ?', ['openid']);
try {
accountDb.transaction(() => {
accountDb.mutate('DELETE FROM sessions');
accountDb.mutate(
`DELETE FROM user_access
WHERE user_access.user_id IN (
SELECT users.id
FROM users
WHERE users.user_name <> ?
);`,
[''],
);
accountDb.mutate('DELETE FROM users WHERE user_name <> ?', ['']);
accountDb.mutate('DELETE FROM auth WHERE method = ?', ['openid']);
});
} catch (err) {
console.error('Error cleaning up openid information:', err);
return { error: 'database-error' };
}
}

export function getSession(token) {
Expand Down
17 changes: 13 additions & 4 deletions src/scripts/enable-openid.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,19 @@ if (needsBootstrap()) {

if (error) {
console.log('Error enabling openid:', error);
console.log(
'Please report this as an issue: https://github.com/actualbudget/actual-server/issues',
);
process.exit(2);
if (error === 'invalid-login-settings') {
console.log(
'Error configuring OpenID. Please verify that the configuration file or environment variables are correct.',
);

process.exit(1);
} else {
console.log(
'Please report this as an issue: https://github.com/actualbudget/actual-server/issues',
);

process.exit(2);
}
}
console.log('OpenID enabled!');
console.log(
Expand Down

0 comments on commit f516740

Please sign in to comment.