From 051472ca6c220ee43bbae5b9e4f8987a892cbf2f Mon Sep 17 00:00:00 2001
From: Rafael Monnerat <rafael@nexedi.com>
Date: Wed, 4 Oct 2017 11:50:08 +0200
Subject: [PATCH] ERP5LoginUserManager: Check Assignment is only meaninfull for
 Persons

---
 product/ERP5Security/ERP5LoginUserManager.py | 21 ++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/product/ERP5Security/ERP5LoginUserManager.py b/product/ERP5Security/ERP5LoginUserManager.py
index 797984f2ec..2e00d8bddd 100644
--- a/product/ERP5Security/ERP5LoginUserManager.py
+++ b/product/ERP5Security/ERP5LoginUserManager.py
@@ -113,16 +113,17 @@ class ERP5LoginUserManager(BasePlugin):
       return
     if user_value.getValidationState() == 'deleted':
       return
-    now = DateTime()
-    for assignment in user_value.contentValues(portal_type="Assignment"):
-      if assignment.getValidationState() == "open" and (
-        not assignment.hasStartDate() or assignment.getStartDate() <= now
-      ) and (
-        not assignment.hasStopDate() or assignment.getStopDate() >= now
-      ):
-        break
-    else:
-      return
+    if user_value.getPortalType() in ('Person', ):
+      now = DateTime()
+      for assignment in user_value.contentValues(portal_type="Assignment"):
+        if assignment.getValidationState() == "open" and (
+          not assignment.hasStartDate() or assignment.getStartDate() <= now
+        ) and (
+          not assignment.hasStopDate() or assignment.getStopDate() >= now
+        ):
+          break
+      else:
+        return
     is_authentication_policy_enabled = self.getPortalObject().portal_preferences.isAuthenticationPolicyEnabled()
     if check_password:
       password = credentials.get('password')
-- 
2.30.9