stages/authenticator: actually update last_used (#10813)

This commit is contained in:
Marc 'risson' Schmitt
2024-08-08 14:19:12 +02:00
committed by GitHub
parent fd0127ae2a
commit 0b6fb8ff5a

View File

@ -5,6 +5,7 @@ from hashlib import sha256
from django.conf import settings
from django.http import HttpRequest, HttpResponse
from django.utils.timezone import now
from django.utils.translation import gettext_lazy as _
from jwt import PyJWTError, decode, encode
from rest_framework.fields import CharField, IntegerField, ListField, UUIDField
@ -12,6 +13,7 @@ from rest_framework.serializers import ValidationError
from authentik.core.api.utils import JSONDictField, PassiveSerializer
from authentik.core.models import User
from authentik.events.middleware import audit_ignore
from authentik.events.models import Event, EventAction
from authentik.flows.challenge import ChallengeResponse, WithUserInfoChallenge
from authentik.flows.exceptions import FlowSkipStageException, StageInvalidException
@ -143,6 +145,9 @@ class AuthenticatorValidationChallengeResponse(ChallengeResponse):
self.stage.executor.plan.context[PLAN_CONTEXT_METHOD_ARGS]["mfa_devices"].append(
self.device
)
with audit_ignore():
self.device.last_used = now()
self.device.save()
return attrs