Adding otpseed as user works

This commit is contained in:
Nico Schottelius 2018-12-30 22:51:34 +01:00
parent 7ab29862f6
commit 1e2d834c59
2 changed files with 9 additions and 10 deletions

View file

@ -13,16 +13,15 @@ class OTPSeed(AbstractUser):
class Meta:
unique_together = (('name', 'realm'),)
def save(self, *args, **kwargs):
"""
inject username to ensure it stays unique / is setup at all
"""
self.username = "{}@{}".format(self.name, self.realm)
super().save(*args, **kwargs)
def __str__(self):
return "'{}'@{}".format(self.name, self.realm)
@property
def auth_name(self):
print("authname: {}".format(self))
@auth_name.setter
def auth_name(self):
print("authname: {}".format(self))
return "'{}'@{} -- {}".format(self.name, self.realm, self.username)
from otpauth.serializer import TokenSerializer

View file

@ -30,7 +30,7 @@ from otpauth.models import OTPSeed
class OTPVerifyViewSet(viewsets.ModelViewSet):
serializer_class = TokenSerializer
serializer_class = OTPSerializer
queryset = OTPSeed.objects.all()
def list(self, request):