Compare commits

...

10 commits

Author SHA1 Message Date
laurentlemercier
f01c91ae06
Merge 165a944822 into d451e06e84 2025-01-05 09:52:52 -05:00
Louis Lam
d451e06e84 Update dependencies
Some checks failed
Node.js CI - Dockge / ci (22, ARM) (push) Has been cancelled
Node.js CI - Dockge / ci (22, ARM64) (push) Has been cancelled
Node.js CI - Dockge / ci (22, macos-latest) (push) Has been cancelled
Node.js CI - Dockge / ci (22, ubuntu-latest) (push) Has been cancelled
Node.js CI - Dockge / ci (22, windows-latest) (push) Has been cancelled
json-yaml-validate / json-yaml-validate (push) Has been cancelled
2025-01-04 18:14:17 +08:00
laurentlemercier
165a944822
Update reset-password.ts
Spaces...
2024-03-10 23:49:19 +01:00
laurentlemercier
8533d18723
Update reset-password.ts
Spaces...
2024-03-10 23:41:19 +01:00
laurentlemercier
d5e8f17aa1
Update reset-password.ts
Indent changes...
2024-03-10 23:34:03 +01:00
laurentlemercier
c451067ac4
Update reset-password.ts
Set User and Password (previous version had a bug).
docker exec --e USER=uservalue -e PASSWORD=passwordvalue -it dockge npm run reset-password
2024-03-10 23:18:50 +01:00
laurentlemercier
9615b844c3
Update reset-password.ts 2024-02-11 23:11:39 +01:00
laurentlemercier
ff922232c1
Update reset-password.ts 2024-02-11 23:09:46 +01:00
laurentlemercier
be72cdbffe
Update compose.yaml
Usefull for interactive action within the container
2024-02-11 22:58:08 +01:00
laurentlemercier
4fe1625f8d
Update reset-password.ts
You can use a variable in order to set password value : 
docker exec -e PASSWORD=value -it dockge npm run reset-password
and you still have the standard behavior when no PASSWORD provided : 
docker exec -it dockge npm run reset-password
2024-02-11 22:56:04 +01:00
4 changed files with 306 additions and 187 deletions

View file

@ -20,3 +20,6 @@ services:
environment: environment:
# Tell Dockge where is your stacks directory # Tell Dockge where is your stacks directory
- DOCKGE_STACKS_DIR=/opt/stacks - DOCKGE_STACKS_DIR=/opt/stacks
# Usefull for interactive action within the container
stdin_open: true # docker run -i
tty: true # docker run -t

View file

@ -6,6 +6,7 @@ import { DockgeServer } from "../backend/dockge-server";
import { log } from "../backend/log"; import { log } from "../backend/log";
import { io } from "socket.io-client"; import { io } from "socket.io-client";
import { BaseRes } from "../common/util-common"; import { BaseRes } from "../common/util-common";
import { generatePasswordHash } from "../backend/password-hash";
console.log("== Dockge Reset Password Tool =="); console.log("== Dockge Reset Password Tool ==");
@ -29,35 +30,67 @@ export const main = async () => {
} }
try { try {
let user ;
// No need to actually reset the password for testing, just make sure no connection problem. It is ok for now. // No need to actually reset the password for testing, just make sure no connection problem. It is ok for now.
if (!process.env.TEST_BACKEND) { if (!process.env.TEST_BACKEND) {
const user = await R.findOne("user"); user = await R.findOne("user");
if (! user ) { if (! user ) {
throw new Error("user not found, have you installed?"); if ( !process.env.USER ) {
throw new Error("user not found or provided, have you installed? Try to set USER and PASSWORD variables ...");
} else {
console.log("Trying to initialise user : " + process.env.USER);
user = R.dispense("user");
user.username = process.env.USER;
user.password = generatePasswordHash(process.env.PASSWORD);
await R.store(user);
console.log("User/Password set 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, user.password);
console.log("You may have to restart");
exit;
}
}
} }
console.log("Found user: " + user.username); let password = "";
let confirmPassword = " ";
while (true) { while (true) {
let password = await question("New Password: ");
let confirmPassword = await question("Confirm New Password: "); 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) { if (password === confirmPassword) {
await User.resetPassword(user.id, password); await User.resetPassword(user.id, password);
console.log("Password reset successfully.");
// Reset all sessions by reset jwt secret // Reset all sessions by reset jwt secret
await server.initJWTSecret(); await server.initJWTSecret();
console.log("Password reset successfully."); console.log("JWT reset successfully.");
// Disconnect all other socket clients of the user // Disconnect all other socket clients of the user
await disconnectAllSocketClients(user.username, password); await disconnectAllSocketClients(user.username, password);
break;
} else { } else {
console.log("Passwords do not match, please try again."); console.log("Passwords do not match, please try again.");
break;
} }
} break;
} }
} catch (e) { } catch (e) {
if (e instanceof Error) { if (e instanceof Error) {
@ -127,3 +160,4 @@ function disconnectAllSocketClients(username : string, password : string) : Prom
if (!process.env.TEST_BACKEND) { if (!process.env.TEST_BACKEND) {
main(); main();
} }

View file

@ -40,7 +40,7 @@
"dotenv": "~16.3.2", "dotenv": "~16.3.2",
"express": "~4.21.2", "express": "~4.21.2",
"express-static-gzip": "~2.1.8", "express-static-gzip": "~2.1.8",
"http-graceful-shutdown": "~3.1.13", "http-graceful-shutdown": "~3.1.14",
"jsonwebtoken": "~9.0.2", "jsonwebtoken": "~9.0.2",
"jwt-decode": "~3.1.2", "jwt-decode": "~3.1.2",
"knex": "~2.5.1", "knex": "~2.5.1",
@ -49,8 +49,8 @@
"promisify-child-process": "~4.1.2", "promisify-child-process": "~4.1.2",
"redbean-node": "~0.3.3", "redbean-node": "~0.3.3",
"semver": "^7.6.3", "semver": "^7.6.3",
"socket.io": "~4.8.0", "socket.io": "~4.8.1",
"socket.io-client": "~4.8.0", "socket.io-client": "~4.8.1",
"timezones-list": "~3.0.3", "timezones-list": "~3.0.3",
"ts-command-line-args": "~2.5.1", "ts-command-line-args": "~2.5.1",
"tsx": "~4.19.2", "tsx": "~4.19.2",
@ -59,7 +59,7 @@
}, },
"devDependencies": { "devDependencies": {
"@actions/github": "^6.0.0", "@actions/github": "^6.0.0",
"@fontsource/jetbrains-mono": "^5.1.1", "@fontsource/jetbrains-mono": "^5.1.2",
"@fortawesome/fontawesome-svg-core": "6.4.2", "@fortawesome/fontawesome-svg-core": "6.4.2",
"@fortawesome/free-regular-svg-icons": "6.4.2", "@fortawesome/free-regular-svg-icons": "6.4.2",
"@fortawesome/free-solid-svg-icons": "6.4.2", "@fortawesome/free-solid-svg-icons": "6.4.2",
@ -81,19 +81,19 @@
"cross-env": "~7.0.3", "cross-env": "~7.0.3",
"eslint": "~8.50.0", "eslint": "~8.50.0",
"eslint-plugin-jsdoc": "~46.8.2", "eslint-plugin-jsdoc": "~46.8.2",
"eslint-plugin-vue": "~9.17.0", "eslint-plugin-vue": "~9.32.0",
"prismjs": "~1.29.0", "prismjs": "~1.29.0",
"sass": "~1.68.0", "sass": "~1.68.0",
"typescript": "~5.2.2", "typescript": "~5.2.2",
"unplugin-vue-components": "~0.25.2", "unplugin-vue-components": "~0.25.2",
"vite": "~5.4.8", "vite": "~5.4.11",
"vite-plugin-compression": "~0.5.1", "vite-plugin-compression": "~0.5.1",
"vue": "~3.5.12", "vue": "~3.5.13",
"vue-eslint-parser": "~9.3.2", "vue-eslint-parser": "~9.3.2",
"vue-i18n": "~9.5.0", "vue-i18n": "~10.0.5",
"vue-prism-editor": "2.0.0-alpha.2", "vue-prism-editor": "2.0.0-alpha.2",
"vue-qrcode": "~2.2.2", "vue-qrcode": "~2.2.2",
"vue-router": "~4.2.5", "vue-router": "~4.5.0",
"vue-toastification": "2.0.0-rc.5", "vue-toastification": "2.0.0-rc.5",
"wait-on": "^7.2.0", "wait-on": "^7.2.0",
"xterm-addon-web-links": "~0.9.0" "xterm-addon-web-links": "~0.9.0"

400
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff