Skip to content

Commit

Permalink
feat(cli): Allow unattended password reset via CLI
Browse files Browse the repository at this point in the history
This commit adds a way to reset the admin password via CLI without any
user interaction (unattended operation).

It adds an optional  `new_password` CLI argument that, when present is
used instead of prompting the user for password and password
confirmation.
  • Loading branch information
C-Duv authored and CDuv committed Oct 29, 2023
1 parent d7b9bcf commit e409cb8
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions extra/reset-password.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,17 @@ const main = async () => {
console.log("Found user: " + user.username);

while (true) {
let password = await question("New Password: ");
let confirmPassword = await question("Confirm New Password: ");
let password;
let confirmPassword;

// When called with "--new_password" argument for unattended modification (e.g. npm run reset-password -- --new_password=secret)
if ("new_password" in args) {
console.log("Using password from argument");
password = confirmPassword = args.new_password;
} else {
password = await question("New Password: ");
confirmPassword = await question("Confirm New Password: ");
}

if (password === confirmPassword) {
await User.resetPassword(user.id, password);
Expand Down

0 comments on commit e409cb8

Please sign in to comment.