Adding otpseed as user works
This commit is contained in:
parent
7ab29862f6
commit
1e2d834c59
2 changed files with 9 additions and 10 deletions
|
@ -13,16 +13,15 @@ class OTPSeed(AbstractUser):
|
||||||
class Meta:
|
class Meta:
|
||||||
unique_together = (('name', 'realm'),)
|
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):
|
def __str__(self):
|
||||||
return "'{}'@{}".format(self.name, self.realm)
|
return "'{}'@{} -- {}".format(self.name, self.realm, self.username)
|
||||||
|
|
||||||
@property
|
|
||||||
def auth_name(self):
|
|
||||||
print("authname: {}".format(self))
|
|
||||||
|
|
||||||
@auth_name.setter
|
|
||||||
def auth_name(self):
|
|
||||||
print("authname: {}".format(self))
|
|
||||||
|
|
||||||
from otpauth.serializer import TokenSerializer
|
from otpauth.serializer import TokenSerializer
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ from otpauth.models import OTPSeed
|
||||||
|
|
||||||
|
|
||||||
class OTPVerifyViewSet(viewsets.ModelViewSet):
|
class OTPVerifyViewSet(viewsets.ModelViewSet):
|
||||||
serializer_class = TokenSerializer
|
serializer_class = OTPSerializer
|
||||||
queryset = OTPSeed.objects.all()
|
queryset = OTPSeed.objects.all()
|
||||||
|
|
||||||
def list(self, request):
|
def list(self, request):
|
||||||
|
|
Loading…
Reference in a new issue