Skip to content
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

Merged
merged 4 commits into from
Oct 22, 2020
Merged

Conversation

wojciechUrbanski
Copy link
Contributor

Fixes #439

More user friendly error messages

Wojtek Urbanski added 2 commits October 21, 2020 17:08
* 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]
Copy link
Member

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]
Copy link
Member

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
@adamw adamw merged commit 4b18d23 into master Oct 22, 2020
@mergify mergify bot deleted the more-user-friendly-error-responses branch October 22, 2020 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

More user-friendly messages in error responses
2 participants