mirror of
https://github.com/louislam/dockge.git
synced 2025-02-20 02:25:56 +00:00
Update reset-password.ts
Spaces...
This commit is contained in:
parent
d5e8f17aa1
commit
8533d18723
1 changed files with 46 additions and 47 deletions
|
@ -36,7 +36,7 @@ export const main = async () => {
|
|||
if (!process.env.TEST_BACKEND) {
|
||||
user = await R.findOne("user");
|
||||
|
||||
if (! user ) {
|
||||
if (! user ) {
|
||||
if ( !process.env.USER ) {
|
||||
throw new Error("user not found or provided, have you installed? Try to set USER and PASSWORD variables ...");
|
||||
} else {
|
||||
|
@ -56,50 +56,49 @@ export const main = async () => {
|
|||
console.log("You may have to restart");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let password = "";
|
||||
let confirmPassword = " ";
|
||||
|
||||
|
||||
while (true) {
|
||||
|
||||
if (process.env.PASSWORD) {
|
||||
console.log("Found password : " + process.env.PASSWORD) ;
|
||||
password = process.env.PASSWORD ;
|
||||
confirmPassword = process.env.PASSWORD ;
|
||||
}
|
||||
else {
|
||||
console.log("No found password: " ) ;
|
||||
password = await question("New Password: ");
|
||||
confirmPassword = await question("Confirm New Password: ");
|
||||
}
|
||||
|
||||
if (password === confirmPassword) {
|
||||
await User.resetPassword(user.id, password);
|
||||
console.log("Password reset successfully.");
|
||||
|
||||
// Reset all sessions by reset jwt secret
|
||||
await server.initJWTSecret();
|
||||
|
||||
console.log("JWT reset successfully.");
|
||||
|
||||
// Disconnect all other socket clients of the user
|
||||
await disconnectAllSocketClients(user.username, password);
|
||||
|
||||
} else {
|
||||
console.log("Passwords do not match, please try again.");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} catch (e) {
|
||||
if (e instanceof Error) {
|
||||
console.error("Error: " + e.message);
|
||||
}
|
||||
}
|
||||
|
||||
let password = "";
|
||||
let confirmPassword = " ";
|
||||
|
||||
while (true) {
|
||||
|
||||
if (process.env.PASSWORD) {
|
||||
console.log("Found password : " + process.env.PASSWORD) ;
|
||||
password = process.env.PASSWORD ;
|
||||
confirmPassword = process.env.PASSWORD ;
|
||||
}
|
||||
else {
|
||||
console.log("No found password: " ) ;
|
||||
password = await question("New Password: ");
|
||||
confirmPassword = await question("Confirm New Password: ");
|
||||
}
|
||||
|
||||
if (password === confirmPassword) {
|
||||
await User.resetPassword(user.id, password);
|
||||
console.log("Password reset successfully.");
|
||||
|
||||
// Reset all sessions by reset jwt secret
|
||||
await server.initJWTSecret();
|
||||
|
||||
console.log("JWT reset successfully.");
|
||||
|
||||
// Disconnect all other socket clients of the user
|
||||
await disconnectAllSocketClients(user.username, password);
|
||||
|
||||
} else {
|
||||
console.log("Passwords do not match, please try again.");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} catch (e) {
|
||||
if (e instanceof Error) {
|
||||
console.error("Error: " + e.message);
|
||||
}
|
||||
}
|
||||
|
||||
await Database.close();
|
||||
rl.close();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue