From 886580a02c852c031a8b206b2a497e3ba60ece2d Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Mon, 1 Mar 2010 00:24:39 +0100 Subject: [PATCH] Raise exception if user exists --- sso/models.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sso/models.py b/sso/models.py index 0e21e33..f22c865 100644 --- a/sso/models.py +++ b/sso/models.py @@ -10,6 +10,9 @@ from services import get_api class CorporateOnlyService(Exception): pass +class ExistingUser(Exception): + pass + ## Models class SSOUser(models.Model): @@ -84,6 +87,8 @@ class ServiceAccount(models.Model): if self.active: if not api.check_user(self.username): api.add_user(self.username, self.password) + else: + raise ExistingUser('Username %s has already been took' % self.username) else: if api.check_user(self.username): api.delete_user(self.username)