mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 14:52:15 +00:00
Raise exception if user exists
This commit is contained in:
@@ -10,6 +10,9 @@ from services import get_api
|
|||||||
class CorporateOnlyService(Exception):
|
class CorporateOnlyService(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class ExistingUser(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
## Models
|
## Models
|
||||||
|
|
||||||
class SSOUser(models.Model):
|
class SSOUser(models.Model):
|
||||||
@@ -84,6 +87,8 @@ class ServiceAccount(models.Model):
|
|||||||
if self.active:
|
if self.active:
|
||||||
if not api.check_user(self.username):
|
if not api.check_user(self.username):
|
||||||
api.add_user(self.username, self.password)
|
api.add_user(self.username, self.password)
|
||||||
|
else:
|
||||||
|
raise ExistingUser('Username %s has already been took' % self.username)
|
||||||
else:
|
else:
|
||||||
if api.check_user(self.username):
|
if api.check_user(self.username):
|
||||||
api.delete_user(self.username)
|
api.delete_user(self.username)
|
||||||
|
|||||||
Reference in New Issue
Block a user