-
-
Notifications
You must be signed in to change notification settings - Fork 648
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added command lines to enable/disable openid from console (#527)
* Added command lines to enable/disable openid * md * Update src/scripts/disable-openid.js Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * changed error codes based on code rabbit review * fix for github auth * code review --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
- Loading branch information
1 parent
6c57b4e
commit 2ef3971
Showing
7 changed files
with
141 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { | ||
disableOpenID, | ||
getActiveLoginMethod, | ||
needsBootstrap, | ||
} from '../account-db.js'; | ||
import { promptPassword } from '../util/prompt.js'; | ||
|
||
if (needsBootstrap()) { | ||
console.log('System needs to be bootstrapped first. OpenID is not enabled.'); | ||
|
||
process.exit(1); | ||
} else { | ||
console.log('To disable OpenID, you have to enter your server password:'); | ||
try { | ||
const loginMethod = getActiveLoginMethod(); | ||
console.log(`Current login method: ${loginMethod}`); | ||
|
||
if (loginMethod === 'password') { | ||
console.log('OpenID already disabled.'); | ||
process.exit(0); | ||
} | ||
|
||
const password = await promptPassword(); | ||
const { error } = (await disableOpenID({ password })) || {}; | ||
|
||
if (error) { | ||
console.log('Error disabling OpenID:', error); | ||
console.log( | ||
'Please report this as an issue: https://github.com/actualbudget/actual-server/issues', | ||
); | ||
process.exit(2); | ||
} | ||
console.log('OpenID disabled!'); | ||
console.log( | ||
'Note: you will need to log in with the password on any browsers or devices that are currently logged in.', | ||
); | ||
} catch (err) { | ||
console.log('Unexpected error:', err); | ||
console.log( | ||
'Please report this as an issue: https://github.com/actualbudget/actual-server/issues', | ||
); | ||
process.exit(2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { | ||
enableOpenID, | ||
getActiveLoginMethod, | ||
needsBootstrap, | ||
} from '../account-db.js'; | ||
import finalConfig from '../load-config.js'; | ||
|
||
if (needsBootstrap()) { | ||
console.log( | ||
'It looks like you don’t have a password set yet. Password is the fallback authentication method when using OpenID. Execute the command reset-password before using this command!', | ||
); | ||
|
||
process.exit(1); | ||
} else { | ||
console.log('Enabling openid based on Environment variables or config.json'); | ||
try { | ||
const loginMethod = getActiveLoginMethod(); | ||
console.log(`Current login method: ${loginMethod}`); | ||
|
||
if (loginMethod === 'openid') { | ||
console.log('OpenID already enabled.'); | ||
process.exit(0); | ||
} | ||
const { error } = (await enableOpenID(finalConfig)) || {}; | ||
|
||
if (error) { | ||
console.log('Error enabling openid:', error); | ||
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( | ||
'Note: The first user to login with OpenID will be the owner of the server.', | ||
); | ||
} catch (err) { | ||
console.log('Unexpected error:', err); | ||
console.log( | ||
'Please report this as an issue: https://github.com/actualbudget/actual-server/issues', | ||
); | ||
process.exit(2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
category: Enhancements | ||
authors: [lelemm] | ||
--- | ||
|
||
Commands to enable/disable OpenID from console. Also, enabling to login with oauth2 (for github). |