Revision 591d0505
b/snf-astakos-app/astakos/im/forms.py | ||
---|---|---|
254 | 254 |
for user in AstakosUser.objects.filter(email = email): |
255 | 255 |
if user.provider == 'shibboleth': |
256 | 256 |
raise forms.ValidationError(_("This email is already associated with another shibboleth account.")) |
257 |
elif not user.is_active: |
|
258 |
raise forms.ValidationError(_("This email is already associated with an inactive account. \ |
|
259 |
You need to wait to be activated before being able to switch to a shibboleth account.")) |
|
257 | 260 |
super(ShibbolethUserCreationForm, self).clean_email() |
258 | 261 |
return email |
259 | 262 |
|
b/snf-astakos-app/astakos/im/models.py | ||
---|---|---|
137 | 137 |
if not self.provider: |
138 | 138 |
self.provider = 'local' |
139 | 139 |
report_user_event(self) |
140 |
self.full_clean()
|
|
140 |
self.validate_unique_email_isactive()
|
|
141 | 141 |
super(AstakosUser, self).save(**kwargs) |
142 | 142 |
|
143 | 143 |
# set group if does not exist |
... | ... | |
170 | 170 |
return True |
171 | 171 |
return False |
172 | 172 |
|
173 |
def validate_unique(self, exclude=None):
|
|
173 |
def validate_unique_email_isactive(self):
|
|
174 | 174 |
""" |
175 | 175 |
Implements a unique_together constraint for email and is_active fields. |
176 | 176 |
""" |
177 |
super(AstakosUser, self).validate_unique(exclude) |
|
178 |
|
|
179 | 177 |
q = AstakosUser.objects.exclude(username = self.username) |
180 | 178 |
q = q.filter(email = self.email) |
181 | 179 |
q = q.filter(is_active = self.is_active) |
Also available in: Unified diff