diff --git a/passbook/core/auth/view.py b/passbook/core/auth/view.py index 80f7bd835..81e6b4816 100644 --- a/passbook/core/auth/view.py +++ b/passbook/core/auth/view.py @@ -66,7 +66,7 @@ class AuthenticationView(UserPassesTestMixin, View): for factor in _all_factors: policy_engine = PolicyEngine(factor.policies.all()) policy_engine.for_user(self.pending_user).with_request(request).build() - if policy_engine.result[0]: + if policy_engine.passing: self.pending_factors.append((factor.uuid.hex, factor.type)) # Read and instantiate factor from session factor_uuid, factor_class = None, None diff --git a/passbook/core/policies.py b/passbook/core/policies.py index 37050a2d0..f26919cef 100644 --- a/passbook/core/policies.py +++ b/passbook/core/policies.py @@ -79,3 +79,8 @@ class PolicyEngine: if not passing: return False, messages return True, messages + + @property + def passing(self): + """Only get true/false if user passes""" + return self.result[0] diff --git a/passbook/core/templatetags/passbook_user_settings.py b/passbook/core/templatetags/passbook_user_settings.py index f6e11df6c..8e529d68c 100644 --- a/passbook/core/templatetags/passbook_user_settings.py +++ b/passbook/core/templatetags/passbook_user_settings.py @@ -17,6 +17,6 @@ def user_factors(context): _link = factor.has_user_settings() policy_engine = PolicyEngine(factor.policies.all()) policy_engine.for_user(user).with_request(context.get('request')).build() - if policy_engine.result[0] and _link: + if policy_engine.passing and _link: matching_factors.append(_link) return matching_factors diff --git a/passbook/saml_idp/views.py b/passbook/saml_idp/views.py index e1d4367ee..682d53efa 100644 --- a/passbook/saml_idp/views.py +++ b/passbook/saml_idp/views.py @@ -105,7 +105,7 @@ class LoginProcessView(ProviderMixin, LoginRequiredMixin, View): """Check if user has access to application""" policy_engine = PolicyEngine(self.provider.application.policies.all()) policy_engine.for_user(self.request.user).with_request(self.request).build() - return policy_engine.result + return policy_engine.passing def get(self, request, application): """Handle get request, i.e. render form"""