( where: Pick<User, 'username'> | Pick<User, 'id'>, password: Password['hash'], )
| 218 | } |
| 219 | |
| 220 | export async function verifyUserPassword( |
| 221 | where: Pick<User, 'username'> | Pick<User, 'id'>, |
| 222 | password: Password['hash'], |
| 223 | ) { |
| 224 | const userWithPassword = await prisma.user.findUnique({ |
| 225 | where, |
| 226 | select: { id: true, password: { select: { hash: true } } }, |
| 227 | }) |
| 228 | |
| 229 | if (!userWithPassword || !userWithPassword.password) { |
| 230 | return null |
| 231 | } |
| 232 | |
| 233 | const isValid = await bcrypt.compare(password, userWithPassword.password.hash) |
| 234 | |
| 235 | if (!isValid) { |
| 236 | return null |
| 237 | } |
| 238 | |
| 239 | return { id: userWithPassword.id } |
| 240 | } |
no outgoing calls
no test coverage detected