Set name, realm and seed for superusers also

This commit is contained in:
PCoder 2019-09-26 15:26:10 +05:30
parent 273a1acf01
commit 9703eb6538

View file

@ -4,6 +4,7 @@ from rest_framework import exceptions
from rest_framework import authentication from rest_framework import authentication
import json import json
import logging import logging
import pyotp
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -25,6 +26,8 @@ class OTPSeed(AbstractUser):
self.username = "{}@{}".format(self.name, self.realm) self.username = "{}@{}".format(self.name, self.realm)
else: else:
self.name = self.username self.name = self.username
self.realm = "ungleich-admin"
self.seed = pyotp.random_base32()
super().save(*args, **kwargs) super().save(*args, **kwargs)