Skip to content
This repository has been archived by the owner on Mar 10, 2024. It is now read-only.

refector(script): use random password for createAdmin #29

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/scripts/createAdmin.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { nanoid } from 'nanoid';
import { UserController } from '../controllers/user';

const userController = new UserController();
await userController.register({ username: 'admin', id: 'admin', password: '12345678', role: 'admin' });
console.log('Created default admin user. \nUserID: `admin` \nUsername: `admin` \nPassword: `12345678`');
const admin = await userController.login('admin', '12345678');
const password = nanoid(10);
await userController.register({ username: 'admin', id: 'admin', password: password, role: 'admin' });
console.log(`Created default admin user. \nUserID: 'admin' \nUsername: 'admin' \nPassword: '${password}'`);
const admin = await userController.login('admin', password);
console.log('Admin AccessToken:');
console.log(admin?.accessToken);