MCPcopy
hub / github.com/epicweb-dev/epic-stack / verifyUserPassword

Function verifyUserPassword

app/utils/auth.server.ts:220–240  ·  view source on GitHub ↗
(
	where: Pick<User, 'username'> | Pick<User, 'id'>,
	password: Password['hash'],
)

Source from the content-addressed store, hash-verified

218}
219
220export 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}

Callers 3

actionFunction · 0.90
loginFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected