stages/authenticator_validate: fix variable shadowing, optimization

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-09-01 19:54:54 +02:00
parent 0be873025a
commit 26fd66d831
1 changed files with 10 additions and 9 deletions

View File

@ -52,18 +52,19 @@ def get_webauthn_challenge(request: HttpRequest, device: WebAuthnDevice) -> dict
request.session["challenge"] = challenge.rstrip("=") request.session["challenge"] = challenge.rstrip("=")
assertion = {} assertion = {}
user = device.user
# We want all the user's WebAuthn devices and merge their challenges # We want all the user's WebAuthn devices and merge their challenges
for device in WebAuthnDevice.objects.filter(user=device.user).order_by("name"): for user_device in WebAuthnDevice.objects.filter(user=device.user).order_by("name"):
webauthn_user = WebAuthnUser( webauthn_user = WebAuthnUser(
device.user.uid, user.uid,
device.user.username, user.username,
device.user.name, user.name,
device.user.avatar, user.avatar,
device.credential_id, user_device.credential_id,
device.public_key, user_device.public_key,
device.sign_count, user_device.sign_count,
device.rp_id, user_device.rp_id,
) )
webauthn_assertion_options = WebAuthnAssertionOptions(webauthn_user, challenge) webauthn_assertion_options = WebAuthnAssertionOptions(webauthn_user, challenge)
if assertion == {}: if assertion == {}: