From f70c0a017f66557d4889db4c1a0474cd450512e8 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 28 Jul 2018 04:02:52 +0900 Subject: [PATCH] =?UTF-8?q?=E7=AE=A1=E7=90=86=E8=80=85=E7=94=A8=E3=83=91?= =?UTF-8?q?=E3=82=B9=E3=83=AF=E3=83=BC=E3=83=89=E3=83=AA=E3=82=BB=E3=83=83?= =?UTF-8?q?=E3=83=88=E3=82=B3=E3=83=9E=E3=83=B3=E3=83=89=E3=82=92=E5=AE=9F?= =?UTF-8?q?=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cli/reset-password.js | 29 +++++++++++++++++++++++++++++ docs/manage.en.md | 5 +++++ docs/manage.ja.md | 5 +++++ 3 files changed, 39 insertions(+) create mode 100644 cli/reset-password.js diff --git a/cli/reset-password.js b/cli/reset-password.js new file mode 100644 index 000000000..d94c90f3d --- /dev/null +++ b/cli/reset-password.js @@ -0,0 +1,29 @@ +const mongo = require('mongodb'); +const bcrypt = require('bcryptjs'); +const User = require('../built/models/user').default; + +const args = process.argv.slice(2); + +const user = args[0]; + +const q = user.startsWith('@') ? { + username: user.split('@')[1], + host: user.split('@')[2] || null +} : { _id: new mongo.ObjectID(user) }; + +console.log(`Resetting password for ${user}...`); + +const passwd = 'yo'; + +// Generate hash of password +const hash = bcrypt.hashSync(passwd); + +User.update(q, { + $set: { + password: hash + } +}).then(() => { + console.log(`Password of ${user} is now '${passwd}'`); +}, e => { + console.error(e); +}); diff --git a/docs/manage.en.md b/docs/manage.en.md index 9a4277b39..a7296ce47 100644 --- a/docs/manage.en.md +++ b/docs/manage.en.md @@ -29,6 +29,11 @@ node cli/suspend @syuilo node cli/suspend @syuilo@misskey.xyz ``` +## Reset password +``` shell +node cli/reset-password (User-ID or Username) +``` + ## Clean up cached remote files ``` shell node cli/clean-cached-remote-files diff --git a/docs/manage.ja.md b/docs/manage.ja.md index 924c567d1..f289037ad 100644 --- a/docs/manage.ja.md +++ b/docs/manage.ja.md @@ -29,6 +29,11 @@ node cli/suspend @syuilo node cli/suspend @syuilo@misskey.xyz ``` +## ユーザーのパスワードをリセットする +``` shell +node cli/reset-password (ユーザーID または ユーザー名) +``` + ## キャッシュされたリモートファイルをクリーンアップする ``` shell node cli/clean-cached-remote-files