MCPcopy Create free account
hub / github.com/getsentry/sentry / authenticate

Method authenticate

src/sentry/utils/auth.py:486–507  ·  view source on GitHub ↗
(
        self,
        request: HttpRequest | None,
        username: str | None = None,
        password: str | None = None,
        **kwargs: Any,
    )

Source from the content-addressed store, hash-verified

484 """
485
486 def authenticate(
487 self,
488 request: HttpRequest | None,
489 username: str | None = None,
490 password: str | None = None,
491 **kwargs: Any,
492 ) -> User | None:
493 for user in find_users(username):
494 try:
495 if is_demo_mode_enabled() and is_demo_user(user):
496 return user
497 if user.password:
498 # XXX(joshuarli): This is checked before (and therefore, regardless of outcome)
499 # password checking as a mechanism to drop old password hashers immediately and
500 # then lazily sending out password reset emails.
501 if user.is_password_expired:
502 raise AuthUserPasswordExpired(user)
503 if password is not None and user.check_password(password):
504 return user
505 except ValueError:
506 continue
507 return None
508
509 def user_can_authenticate(self, user: User | AnonymousUser | None) -> bool:
510 return True

Calls 4

is_demo_mode_enabledFunction · 0.90
is_demo_userFunction · 0.90
find_usersFunction · 0.85