mirror of
https://github.com/nowcommunity/nowdatabase.git
synced 2026-10-12 19:13:52 +03:00
Adjust user creation route
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user