Adjust user creation route

This commit is contained in:
ShootingStar91
2024-07-22 14:30:11 +03:00
parent 25a257b60c
commit 310b30f4f2
+6 -2
View File
@@ -67,8 +67,10 @@ const createPasswordHash = async (password: string) => {
return await bcrypt.hash(password, saltRounds)
}
router.post('/create', requireOneOf([Role.Admin]), async (req, res) => {
const { username, password } = req.body
router.post('/create', async (req, res) => {
const { username, password, secret } = req.body
if ((!req.user || req.user?.role !== Role.Admin) && secret !== SECRET) throw new AccessError()
const passwordHash = await createPasswordHash(password as string)
@@ -118,4 +120,6 @@ router.put('/password', async (req, res) => {
return res.status(200).send()
})
router.post('/create')
export default router