Django MIT plugin: Don't crash on users with hidden emails (ASA Trac: #63)
authorGeoffrey Thomas <geofft@mit.edu>
Tue, 24 Jan 2012 06:57:01 +0000 (01:57 -0500)
committerAlex Dehnert <adehnert@mit.edu>
Fri, 3 Feb 2012 09:53:44 +0000 (04:53 -0500)
__init__.py

index 725d660b713858074dd409407f40da558f02df7f..d0f6993c2df941ae3b4bcc6f890e4a7f18653d85 100644 (file)
@@ -41,7 +41,10 @@ class ScriptsRemoteUserBackend(RemoteUserBackend):
         if len(result) == 1:
             user.first_name = result[0][1]['givenName'][0]
             user.last_name = result[0][1]['sn'][0]
-            user.email = result[0][1]['mail'][0]
+            try:
+                user.email = result[0][1]['mail'][0]
+            except KeyError:
+                user.email = username + '@mit.edu'
             try:
                 user.groups.add(auth.models.Group.objects.get(name='mit'))
             except ObjectDoesNotExist: