mirror of
https://codeberg.org/yeentown/barkey
synced 2024-11-21 22:35:11 +00:00
管理者用パスワードリセットコマンドを実装
This commit is contained in:
parent
e4bf0392af
commit
2c6f881093
3 changed files with 39 additions and 0 deletions
29
cli/reset-password.js
Normal file
29
cli/reset-password.js
Normal file
|
@ -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);
|
||||
});
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue