From 5f7fb2e0bd066b1b72ddece600f4906669c16c82 Mon Sep 17 00:00:00 2001
From: Henrik Levkowetz <henrik@levkowetz.com>
Date: Sat, 9 Jun 2018 13:20:14 +0000
Subject: [PATCH] Added a guard against trying to access attributes of a None
 object.  - Legacy-Id: 15236

---
 ietf/ietfauth/views.py | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/ietf/ietfauth/views.py b/ietf/ietfauth/views.py
index 07b4debbc..0a5536094 100644
--- a/ietf/ietfauth/views.py
+++ b/ietf/ietfauth/views.py
@@ -586,20 +586,21 @@ def login(request, extra_context=None):
         user = User.objects.filter(username=username).first()
         #
         require_consent = []
-        if user.person and not user.person.consent:
-            person = user.person
-            if person.name != person.name_from_draft:
-                require_consent.append("full name")
-            if person.ascii != person.name_from_draft:
-                require_consent.append("ascii name")
-            if person.biography:
-                require_consent.append("biography")
-            if user.communitylist_set.exists():
-                require_consent.append("draft notification subscription(s)")
-            for email in person.email_set.all():
-                if not email.origin.split(':')[0] in ['author', 'role', 'reviewer', 'liaison', 'shepherd', ]:
-                    require_consent.append("email address(es)")
         if user:
+            if user.person and not user.person.consent:
+                person = user.person
+                if person.name != person.name_from_draft:
+                    require_consent.append("full name")
+                if person.ascii != person.name_from_draft:
+                    require_consent.append("ascii name")
+                if person.biography:
+                    require_consent.append("biography")
+                if user.communitylist_set.exists():
+                    require_consent.append("draft notification subscription(s)")
+                for email in person.email_set.all():
+                    if not email.origin.split(':')[0] in ['author', 'role', 'reviewer', 'liaison', 'shepherd', ]:
+                        require_consent.append("email address(es)")
+
             try:
                 identify_hasher(user.password)
             except ValueError: