check for no password and emailChecked on login

This commit is contained in:
Ulf Gebhardt 2021-11-24 02:20:22 +01:00
parent d5ea64d9ca
commit cf8ca47cc6
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9

View File

@ -160,7 +160,14 @@ export class UserResolver {
const loginUser = await loginUserRepository.findByEmail(email).catch(() => { const loginUser = await loginUserRepository.findByEmail(email).catch(() => {
throw new Error('No user with this credentials') throw new Error('No user with this credentials')
}) })
if (!loginUser.emailChecked) throw new Error('user email not validated') if (!loginUser.emailChecked) {
// TODO we want to catch this on the frontend and ask the user to check his emails or resend code
throw new Error('User email not validated')
}
if (loginUser.password === BigInt(0)) {
// TODO we want to catch this on the frontend and ask the user to check his emails or resend code
throw new Error('User has no password set yet')
}
const passwordHash = SecretKeyCryptographyCreateKey(email, password) // return short and long hash const passwordHash = SecretKeyCryptographyCreateKey(email, password) // return short and long hash
const loginUserPassword = BigInt(loginUser.password.toString()) const loginUserPassword = BigInt(loginUser.password.toString())
if (loginUserPassword !== passwordHash[0].readBigUInt64LE()) { if (loginUserPassword !== passwordHash[0].readBigUInt64LE()) {