Skip to content
Permalink
Browse files

HUE-8675 [core] Fix external users created as superuser

  • Loading branch information...
wing2fly committed Dec 13, 2018
1 parent 74af933 commit 5fa75c3176b2065709021284803aa61e9e72f0a5
@@ -32,7 +32,7 @@ def forwards(self, orm):
# LDAP == 1
# HUE == 0
if up.creation_method == '1':
up.creation_method = UserProfile.CreationMethod.EXTERNAL
up.creation_method = UserProfile.CreationMethod.EXTERNAL.name
elif up.creation_method == '0':
up.creation_method = UserProfile.CreationMethod.HUE
up.save()
@@ -340,7 +340,7 @@ def authenticate(self, request=None, username=None, password=None):
user = find_or_create_user(username, None)
if user is not None and user.is_active:
profile = get_profile(user)
profile.creation_method = UserProfile.CreationMethod.EXTERNAL
profile.creation_method = UserProfile.CreationMethod.EXTERNAL.name
profile.save()
user.is_superuser = is_super

@@ -492,7 +492,7 @@ def authenticate(self, request=None, username=None, password=None, server=None):

if user is not None and user.is_active:
profile = get_profile(user)
profile.creation_method = UserProfile.CreationMethod.EXTERNAL
profile.creation_method = UserProfile.CreationMethod.EXTERNAL.name
profile.save()
user.is_superuser = is_super
user = rewrite_user(user)
@@ -577,7 +577,7 @@ def authenticate(self, request=None, username=None):
user = find_or_create_user(username, None)
if user is not None and user.is_active:
profile = get_profile(user)
profile.creation_method = UserProfile.CreationMethod.EXTERNAL
profile.creation_method = UserProfile.CreationMethod.EXTERNAL.name
profile.save()
user.is_superuser = is_super

@@ -622,7 +622,7 @@ def authenticate(self, remote_user=None):
user = find_or_create_user(username, None)
if user is not None and user.is_active:
profile = get_profile(user)
profile.creation_method = UserProfile.CreationMethod.EXTERNAL
profile.creation_method = UserProfile.CreationMethod.EXTERNAL.name
profile.save()
user.is_superuser = is_super

@@ -46,7 +46,7 @@
from desktop.settings import LOAD_BALANCER_COOKIE

from hadoop.fs.exceptions import WebHdfsException
from useradmin.models import get_profile
from useradmin.models import get_profile, UserProfile
from useradmin.views import ensure_home_directory, require_change_password
from notebook.connectors.base import get_api

@@ -139,6 +139,9 @@ def dt_login(request, from_modal=False):

userprofile.first_login = False
userprofile.last_activity = datetime.now()
# This is to fix a bug in Hue 4.3
if userprofile.creation_method == UserProfile.CreationMethod.EXTERNAL:
userprofile.creation_method = UserProfile.CreationMethod.EXTERNAL.name
userprofile.save()

msg = 'Successful login for user: %s' % user.username
@@ -67,7 +67,7 @@ def authenticate(self, access_token):
user = find_or_create_user(username, password)

profile = get_profile(user)
profile.creation_method = UserProfile.CreationMethod.EXTERNAL
profile.creation_method = UserProfile.CreationMethod.EXTERNAL.name
profile.save()

user.is_superuser = is_super
@@ -67,7 +67,7 @@ def update_user_details(self, user, details, openid_response):

if user is not None and user.is_active:
profile = get_profile(user)
profile.creation_method = UserProfile.CreationMethod.EXTERNAL
profile.creation_method = UserProfile.CreationMethod.EXTERNAL.name
profile.save()
user.is_superuser = is_super
user = rewrite_user(user)
@@ -90,7 +90,7 @@ def update_user(self, user, attributes, attribute_mapping, force_save=False):
if user is not None and user.is_active:
user.username = force_username_case(user.username)
profile = get_profile(user)
profile.creation_method = UserProfile.CreationMethod.EXTERNAL
profile.creation_method = UserProfile.CreationMethod.EXTERNAL.name
profile.save()
user.is_superuser = is_super
user = rewrite_user(user)

0 comments on commit 5fa75c3

Please sign in to comment.
You can’t perform that action at this time.