Revision 27e26a41 snf-astakos-app/astakos/im/views.py

b/snf-astakos-app/astakos/im/views.py
39 39
from functools import wraps
40 40

  
41 41
from django.core.mail import send_mail
42
from django.http import HttpResponse
42
from django.http import HttpResponse, HttpResponseBadRequest
43 43
from django.shortcuts import redirect
44 44
from django.template.loader import render_to_string
45 45
from django.utils.translation import ugettext as _
......
52 52
from django.http import HttpResponseRedirect, HttpResponseBadRequest
53 53
from django.db.utils import IntegrityError
54 54
from django.contrib.auth.views import password_change
55
from django.core.exceptions import ValidationError
55 56

  
56 57
from astakos.im.models import AstakosUser, Invitation, ApprovalTerms
57 58
from astakos.im.activation_backends import get_backend, SimpleBackend
......
440 441
    except AstakosUser.DoesNotExist:
441 442
        user.is_active = True
442 443
        user.email_verified = True
443
        user.save()
444
        try:
445
            user.save()
446
        except ValidationError, e:
447
            return HttpResponseBadRequest(e)
448
        
444 449
    else:
445 450
        # switch the local account to shibboleth one
446 451
        local_user.provider = 'shibboleth'
447 452
        local_user.set_unusable_password()
448 453
        local_user.third_party_identifier = user.third_party_identifier
449
        local_user.save()
454
        try:
455
            local_user.save()
456
        except ValidationError, e:
457
            return HttpResponseBadRequest(e)
450 458
        user.delete()
451 459
        user = local_user
452 460
    

Also available in: Unified diff