Commit 8ec9138e by Őry Máté

school: error msg for sp login wo/ email, fixes #129

parent 76a93346
......@@ -215,4 +215,4 @@ class ViewTestCase(TestCase):
def test_login_without_email(self):
del self.http_headers['email']
resp = self.client.get('/login/', follow=True, **self.http_headers)
print resp.status_code
self.assertEqual(403, resp.status_code)
from datetime import datetime
from django.core.exceptions import ValidationError
from django.core.exceptions import PermissionDenied, ValidationError
from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User, Group as AGroup
......@@ -45,7 +45,11 @@ def login(request):
user.set_unusable_password()
user.first_name = request.META['givenName']
user.last_name = request.META['sn']
user.email = request.META['email']
try:
user.email = request.META['email']
except KeyError:
messages.error(request, _("The identity provider did not pass the mandatory e-mail data."))
raise PermissionDenied()
user.save()
p, created = Person.objects.get_or_create(code=user.username)
p.user_id = user.id
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment