loginWithEmail method
Implementation
Future<String> loginWithEmail({
required String email,
required String password,
}) async {
AuthModel? savedModel = await authDbProvider.getUserByEmail(email);
if (savedModel == null) {
throw NoUserRegisteredException();
}
bool rightPassword =
SecurePassword(password).checkPassword(savedModel.passwordHash);
if (!rightPassword) {
throw InvalidPassword();
}
// create and send the new jwt for the user
String jwtToken =
await authDbProvider.createJwtAndSave(savedModel.id, email);
// get the user data to return it to the
return jwtToken;
}