feat: add register, checkUsername, update swagger

This commit is contained in:
wancat committed 2023-09-12 23:01:49 +08:00
1 parent 04a0b21cf6
commit b55b7aa1ec
6 files changed
+118 -23

No files matched your search

+5 -1
View File
@@ -3,6 +3,10 @@ import bcrypt from 'bcrypt'
import config from '../config.js'
import User from '../models/user.js'
export function hashPassword(password) {
return bcrypt.hash(password, 10)
}
export async function createTestUser() {
let user = await User.findOne({ username: 'testUser' })
if (!user) {
@@ -10,7 +14,7 @@ export async function createTestUser() {
username: 'testUser',
email: 'test@example.com',
})
user.hashedPassword = await bcrypt.hash('testPassword', 10)
user.hashedPassword = await hashPassword('testPassword')
await user.save()
}
}