-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More user friendly error messages #442
Conversation
* Login and ChangePassword operations returns Unauthorized in case of unknown user instead of NotFound
_ = logger.debug(s"Changing password for user: $userId") | ||
_ <- userModel.updatePassword(userId, User.hashPassword(newPassword)) | ||
} yield () | ||
|
||
private def userOrNotFound(op: ConnectionIO[Option[User]]): ConnectionIO[User] = { | ||
op.flatMap { | ||
case Some(user) => user.pure[ConnectionIO] | ||
case None => Fail.NotFound("user").raiseError[ConnectionIO, User] | ||
case None => Fail.Unauthorized("Incorrect login/email or password").raiseError[ConnectionIO, User] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably extract this message to a constant so that it's not repeated, and the fact that the constant is used twice will also be informative for the developer
@@ -27,7 +27,7 @@ class PasswordResetService( | |||
|
|||
def forgotPassword(loginOrEmail: String): ConnectionIO[Unit] = { | |||
userModel.findByLoginOrEmail(loginOrEmail.lowerCased).flatMap { | |||
case None => Fail.NotFound("user").raiseError[ConnectionIO, Unit] | |||
case None => ().pure[ConnectionIO] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add a debug-log so that it's visible in the logs that the user hasn't been found? (as it's not visible in the UI)
* Adding log message if user can't be found during forgotPassword operation
Fixes #439
More user friendly error messages