mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
feat: add register, checkUsername, update swagger
This commit is contained in:
1 parent
04a0b21cf6
commit
b55b7aa1ec
6 files changed
+118
-23
No files matched your search
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user