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

fix: Return 401 when basic auth credentials are invalid instead of failing with Internal Server Error (DEV-4585) #3514

Merged
merged 1 commit into from
Feb 21, 2025

Conversation

seakayone
Copy link
Contributor

@seakayone seakayone commented Feb 20, 2025

Description

Basic Auth worked correctly when correct credentials are presented, this fixes the correct status code in case of invalid credentials.

…iling with Internal Server Error

Basic Auth worked correctly when correct credentials are presented, this fixes the correct status code in case of invalid credentials.
@seakayone seakayone changed the title fix: Return 401 when basic auth credentials are invalid instead of failing with Internal Server Error fix: Return 401 when basic auth credentials are invalid instead of failing with Internal Server Error (DEV-4585) Feb 20, 2025
Copy link

linear bot commented Feb 20, 2025

email <- ZIO.fromEither(Email.from(basic.username))
password <- ZIO.fromOption(basic.password)
user <- authenticator.authenticate(email, password)
} yield user._1).orElseFail(BadCredentialsException("Invalid credentials.")).asRight,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.asRight failed, need to use .either.

@seakayone seakayone merged commit eb22b2e into main Feb 21, 2025
11 checks passed
@seakayone seakayone deleted the fix/basic-auth branch February 21, 2025 08:26
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.

4 participants