Set username for non-superusers only

This commit is contained in:
PCoder 2019-09-26 15:10:16 +05:30
parent 79458d54cb
commit 3f37fe4826

View file

@ -21,7 +21,11 @@ class OTPSeed(AbstractUser):
"""
inject username to ensure it stays unique / is setup at all
"""
self.username = "{}@{}".format(self.name, self.realm)
if not self.is_superuser:
self.username = "{}@{}".format(self.name, self.realm)
else:
self.name = self.username
super().save(*args, **kwargs)
def __str__(self):