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

Use the correct metric name when the user does not exist #609

Merged
merged 4 commits into from
Sep 4, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions fixbackend/auth/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,14 @@
user = await user_manager.authenticate(credentials)

if user is None or not user.is_active:
maybe_existing = await user_manager.get_by_email(credentials.username)
metric = FailedLoginAttempts
if maybe_existing:
metric = FailedLoginAttempts.labels(user_id=maybe_existing.id)
metric = FailedLoginAttempts.labels(user_id=None)
try:
maybe_existing = await user_manager.get_by_email(credentials.username)
if maybe_existing:
metric = FailedLoginAttempts.labels(user_id=maybe_existing.id)
except Exception:

Check warning on line 190 in fixbackend/auth/router.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

fixbackend/auth/router.py#L190

Try, Except, Pass detected.
pass

metric.inc()
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
Expand Down
Loading