Skip to content

Commit

Permalink
Merge development
Browse files Browse the repository at this point in the history
  • Loading branch information
faucomte97 committed Feb 22, 2024
2 parents 996d263 + cc76c1a commit 94738c4
Show file tree
Hide file tree
Showing 6 changed files with 277 additions and 111 deletions.
114 changes: 57 additions & 57 deletions backend/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions backend/api/serializers/auth_factor.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Meta:
# pylint: disable-next=missing-function-docstring
def validate_type(self, value: str):
if AuthFactor.objects.filter(
user=self.request.user, type=value
user=self.request.auth_user, type=value
).exists():
raise serializers.ValidationError(
"You already have this authentication factor enabled.",
Expand All @@ -34,7 +34,7 @@ def validate_type(self, value: str):
return value

def create(self, validated_data):
user = self.request.user
user = self.request.auth_user
if not user.userprofile.otp_secret:
user.userprofile.otp_secret = pyotp.random_base32()
user.userprofile.save()
Expand All @@ -51,6 +51,6 @@ def to_representation(self, instance):
):
representation[
"totp_provisioning_uri"
] = self.request.user.totp_provisioning_uri
] = self.request.auth_user.totp_provisioning_uri

return representation
Loading

0 comments on commit 94738c4

Please sign in to comment.