mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
feat: add testing setup in backend
This commit is contained in:
1 parent
cb376caff0
commit
1f77328362
15 files changed
+92
-100
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { matchedData } from 'express-validator'
|
||||
import { User } from '@linux-odyssey/models'
|
||||
import { genJWT, hashPassword } from '../../utils/auth.js'
|
||||
import { genJWT } from '../../utils/auth.js'
|
||||
import { createUser } from '../../models/userManager.js'
|
||||
import { asyncHandler } from '../../middleware/error.js'
|
||||
|
||||
export const issueToken = asyncHandler(async (req, res) => {
|
||||
@@ -16,12 +17,7 @@ export const issueToken = asyncHandler(async (req, res) => {
|
||||
export const register = asyncHandler(async (req, res, next) => {
|
||||
const { username, password, email } = matchedData(req)
|
||||
|
||||
const user = new User({
|
||||
username,
|
||||
email,
|
||||
})
|
||||
user.hashedPassword = await hashPassword(password)
|
||||
await user.save()
|
||||
const user = await createUser(username, email, password)
|
||||
req.login(user, (err) => {
|
||||
if (err) {
|
||||
next(err)
|
||||
|
||||
Reference in new issue
Block a user