Expand scope of enterprise user types.

This commit is contained in:
Aaron Tan
2017-06-19 16:57:12 -04:00
parent 8061667ace
commit 70cccb0e57
5 changed files with 57 additions and 11 deletions

View File

@@ -98,6 +98,20 @@ def user_is_system_auditor(user, tf):
User.add_to_class('is_system_auditor', user_is_system_auditor)
def user_is_in_enterprise_category(user, category):
ret = (category,) in user.enterprise_auth.all().values_list('provider') and not user.has_usable_password()
# NOTE: this if-else block ensures existing enterprise users are still able to
# log in. Remove it in a future release
if category == 'radius':
ret = ret or not user.has_usable_password()
elif category == 'saml':
ret = ret or user.social_auth.all()
return ret
User.add_to_class('is_in_enterprise_category', user_is_in_enterprise_category)
# Import signal handlers only after models have been defined.
import awx.main.signals # noqa