Return next() function
This commit is contained in:
parent
295acb1c84
commit
a8e5b57363
4 changed files with 6 additions and 4 deletions
|
@ -15,5 +15,5 @@ export default async function checkPasswordIsValid(
|
||||||
const result = await bcrypt.compare(password, player.passwordHash)
|
const result = await bcrypt.compare(password, player.passwordHash)
|
||||||
if (!result) return sendError(req, res, errors.wrongPassword)
|
if (!result) return sendError(req, res, errors.wrongPassword)
|
||||||
|
|
||||||
next()
|
return next()
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,13 +7,15 @@ async function createPlayerDB(
|
||||||
password: string,
|
password: string,
|
||||||
next: (player: Player) => void
|
next: (player: Player) => void
|
||||||
) {
|
) {
|
||||||
return await prisma.player.create({
|
const player = await prisma.player.create({
|
||||||
data: {
|
data: {
|
||||||
username,
|
username,
|
||||||
passwordHash: await bcrypt.hash(password, 10),
|
passwordHash: await bcrypt.hash(password, 10),
|
||||||
anonymous: false,
|
anonymous: false,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
return next(player)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default createPlayerDB
|
export default createPlayerDB
|
||||||
|
|
|
@ -20,5 +20,5 @@ export default async function getPlayerByIdDB(
|
||||||
return sendError(req, res, errors.playerNotFound)
|
return sendError(req, res, errors.playerNotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
next(player)
|
return next(player)
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,5 +25,5 @@ export default async function getPlayerByNameDB(
|
||||||
]).catch(() => null)
|
]).catch(() => null)
|
||||||
if (player === null) return sendError(req, res, errors.playerNotFound)
|
if (player === null) return sendError(req, res, errors.playerNotFound)
|
||||||
|
|
||||||
next(player)
|
return next(player)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue