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

record when a login used a remembered device #15710

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all 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
16 changes: 14 additions & 2 deletions warehouse/accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,9 @@ def login(request, redirect_field_name=REDIRECT_FIELD_NAME, _form_class=LoginFor

# If the user has enabled two-factor authentication and they do not have
# a valid saved device.
_two_factor_remembered = _check_remember_device_token(request, userid)
two_factor_required = user_service.has_two_factor(userid) and (
not _check_remember_device_token(request, userid)
not _two_factor_remembered
)
if two_factor_required:
two_factor_data = {"userid": userid}
Expand All @@ -278,8 +279,19 @@ def login(request, redirect_field_name=REDIRECT_FIELD_NAME, _form_class=LoginFor
):
redirect_to = request.route_path("manage.projects")

# Construct necessary two_factor information
two_factor_method = (
"device_remembered" if _two_factor_remembered else None
)
two_factor_label = two_factor_method

# Actually perform the login routine for our user.
headers = _login_user(request, userid)
headers = _login_user(
request,
userid,
two_factor_method,
two_factor_label=two_factor_label,
)

# Now that we're logged in we'll want to redirect the user to
# either where they were trying to go originally, or to the default
Expand Down
Loading