feat: `createNewUser` now accepts a password and handles hashing

pull/177/head
tycrek 1 year ago
parent dc2f3937b2
commit 2dad6f13ce
No known key found for this signature in database
GPG Key ID: FF8A54DCE404885A

@ -68,7 +68,7 @@ const migrate = (): Promise<Users> => new Promise(async (resolve, reject) => {
/**
* This is a WIP
*/
export const createNewUser = (username: string, passhash: string, admin: boolean, meta?: { [key: string]: User }): Promise<User> => new Promise(async (resolve, reject) => {
export const createNewUser = (username: string, password: string, admin: boolean, meta?: { [key: string]: User }): Promise<User> => new Promise(async (resolve, reject) => {
// todo: finish this
@ -76,7 +76,7 @@ export const createNewUser = (username: string, passhash: string, admin: boolean
const newUser: User = {
unid: nanoid(),
username,
passhash,
passhash: await bcrypt.hash(password, 10),
token: nanoid(32),
admin,
meta: meta || {}

Loading…
Cancel
Save