|
@@ -400,7 +400,7 @@ def edit_user(request, username=None):
|
|
|
if is_admin(request.user):
|
|
if is_admin(request.user):
|
|
|
return redirect(reverse('about:index'))
|
|
return redirect(reverse('about:index'))
|
|
|
else:
|
|
else:
|
|
|
- return redirect(reverse('desktop_views_home'))
|
|
|
|
|
|
|
+ return JsonResponse({'url': '/hue'})
|
|
|
elif is_admin(request.user):
|
|
elif is_admin(request.user):
|
|
|
if is_embeddable:
|
|
if is_embeddable:
|
|
|
return JsonResponse({'url': '/hue' + reverse(list_users)})
|
|
return JsonResponse({'url': '/hue' + reverse(list_users)})
|
|
@@ -432,7 +432,9 @@ def edit_user(request, username=None):
|
|
|
})
|
|
})
|
|
|
else:
|
|
else:
|
|
|
if request.method == 'POST' and is_embeddable:
|
|
if request.method == 'POST' and is_embeddable:
|
|
|
- return JsonResponse({'status': -1, 'errors': [{'id': f.id_for_label, 'message': list(map(antixss, f.errors))} for f in form if f.errors]})
|
|
|
|
|
|
|
+ return JsonResponse({'status': -1,
|
|
|
|
|
+ 'errors': [{'id': f.id_for_label, 'message': list(map(antixss, f.errors))} for f in form if
|
|
|
|
|
+ f.errors]})
|
|
|
else:
|
|
else:
|
|
|
return render('edit_user.mako', request, {
|
|
return render('edit_user.mako', request, {
|
|
|
'form': form,
|
|
'form': form,
|
|
@@ -887,7 +889,7 @@ def sync_unix_users_and_groups(min_uid, max_uid, min_gid, max_gid, check_shell):
|
|
|
members = group.gr_mem
|
|
members = group.gr_mem
|
|
|
for member in members:
|
|
for member in members:
|
|
|
if member not in user_groups:
|
|
if member not in user_groups:
|
|
|
- user_groups[member] = [ hue_group ]
|
|
|
|
|
|
|
+ user_groups[member] = [hue_group]
|
|
|
else:
|
|
else:
|
|
|
user_groups[member].append(hue_group)
|
|
user_groups[member].append(hue_group)
|
|
|
|
|
|
|
@@ -924,7 +926,7 @@ def _check_remove_last_super(user_obj):
|
|
|
return
|
|
return
|
|
|
|
|
|
|
|
# Is there any other active superuser left?
|
|
# Is there any other active superuser left?
|
|
|
- all_active_su = User.objects.filter(is_superuser__exact = True, is_active__exact = True)
|
|
|
|
|
|
|
+ all_active_su = User.objects.filter(is_superuser__exact=True, is_active__exact=True)
|
|
|
num_active_su = all_active_su.count()
|
|
num_active_su = all_active_su.count()
|
|
|
|
|
|
|
|
if num_active_su < 1:
|
|
if num_active_su < 1:
|
|
@@ -1089,14 +1091,16 @@ def _import_ldap_members(connection, group, ldap_info, count=0, max_count=1, fai
|
|
|
LOG.debug("Importing posix user %s into group %s" % (smart_str(posix_member), smart_str(group.name)))
|
|
LOG.debug("Importing posix user %s into group %s" % (smart_str(posix_member), smart_str(group.name)))
|
|
|
user_info = None
|
|
user_info = None
|
|
|
try:
|
|
try:
|
|
|
- user_info = connection.find_users(posix_member, search_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(), user_name_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(), find_by_dn=False)
|
|
|
|
|
|
|
+ user_info = connection.find_users(posix_member, search_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(),
|
|
|
|
|
+ user_name_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(), find_by_dn=False)
|
|
|
except LdapSearchException as e:
|
|
except LdapSearchException as e:
|
|
|
LOG.warn("Failed to find LDAP users: %s" % e)
|
|
LOG.warn("Failed to find LDAP users: %s" % e)
|
|
|
|
|
|
|
|
if user_info:
|
|
if user_info:
|
|
|
users = _import_ldap_users_info(connection, user_info, failed_users=failed_users)
|
|
users = _import_ldap_users_info(connection, user_info, failed_users=failed_users)
|
|
|
if users:
|
|
if users:
|
|
|
- LOG.debug("Adding member %s represented as users (should be a single user) %s to group %s" % (smart_str(posix_member), smart_str(users), smart_str(group.name)))
|
|
|
|
|
|
|
+ LOG.debug("Adding member %s represented as users (should be a single user) %s to group %s" % (
|
|
|
|
|
+ smart_str(posix_member), smart_str(users), smart_str(group.name)))
|
|
|
group.user_set.add(*users)
|
|
group.user_set.add(*users)
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1125,7 +1129,8 @@ def _sync_ldap_members(connection, group, ldap_info, count=0, max_count=1, faile
|
|
|
user = ldap_access.get_ldap_user(username=user_info['username'])
|
|
user = ldap_access.get_ldap_user(username=user_info['username'])
|
|
|
group.user_set.add(user)
|
|
group.user_set.add(user)
|
|
|
except User.DoesNotExist:
|
|
except User.DoesNotExist:
|
|
|
- LOG.warn("Synchronizing user %s with group %s failed. User does not exist." % (smart_str(user_info['dn']), smart_str(group.name)))
|
|
|
|
|
|
|
+ LOG.warn("Synchronizing user %s with group %s failed. User does not exist." % (
|
|
|
|
|
+ smart_str(user_info['dn']), smart_str(group.name)))
|
|
|
|
|
|
|
|
for group_info in groups_info:
|
|
for group_info in groups_info:
|
|
|
LOG.debug("Synchronizing group %s" % smart_str(group_info['dn']))
|
|
LOG.debug("Synchronizing group %s" % smart_str(group_info['dn']))
|
|
@@ -1140,7 +1145,8 @@ def _sync_ldap_members(connection, group, ldap_info, count=0, max_count=1, faile
|
|
|
LOG.debug("Synchronizing posix user %s with group %s" % (smart_str(posix_member), smart_str(group.name)))
|
|
LOG.debug("Synchronizing posix user %s with group %s" % (smart_str(posix_member), smart_str(group.name)))
|
|
|
users_info = []
|
|
users_info = []
|
|
|
try:
|
|
try:
|
|
|
- users_info = connection.find_users(posix_member, search_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(), user_name_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(), find_by_dn=False)
|
|
|
|
|
|
|
+ users_info = connection.find_users(posix_member, search_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(),
|
|
|
|
|
+ user_name_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(), find_by_dn=False)
|
|
|
except LdapSearchException as e:
|
|
except LdapSearchException as e:
|
|
|
LOG.warn("Failed to find LDAP users: %s" % e)
|
|
LOG.warn("Failed to find LDAP users: %s" % e)
|
|
|
|
|
|
|
@@ -1149,7 +1155,8 @@ def _sync_ldap_members(connection, group, ldap_info, count=0, max_count=1, faile
|
|
|
user = ldap_access.get_ldap_user(username=user_info['username'])
|
|
user = ldap_access.get_ldap_user(username=user_info['username'])
|
|
|
group.user_set.add(user)
|
|
group.user_set.add(user)
|
|
|
except User.DoesNotExist:
|
|
except User.DoesNotExist:
|
|
|
- LOG.warn("Synchronizing posix user %s with group %s failed. User does not exist." % (smart_str(posix_member), smart_str(group.name)))
|
|
|
|
|
|
|
+ LOG.warn("Synchronizing posix user %s with group %s failed. User does not exist." % (
|
|
|
|
|
+ smart_str(posix_member), smart_str(group.name)))
|
|
|
|
|
|
|
|
|
|
|
|
|
def _import_ldap_nested_groups(connection, groupname_pattern, import_members=False, recursive_import_members=False,
|
|
def _import_ldap_nested_groups(connection, groupname_pattern, import_members=False, recursive_import_members=False,
|
|
@@ -1264,7 +1271,8 @@ def _import_ldap_suboordinate_groups(connection, groupname_pattern, import_membe
|
|
|
|
|
|
|
|
for member in members:
|
|
for member in members:
|
|
|
LOG.debug("Importing user %s" % smart_str(member))
|
|
LOG.debug("Importing user %s" % smart_str(member))
|
|
|
- group.user_set.add( *( _import_ldap_users(connection, member, import_by_dn=True, failed_users=failed_users) or [] ) )
|
|
|
|
|
|
|
+ group.user_set.add(
|
|
|
|
|
+ *(_import_ldap_users(connection, member, import_by_dn=True, failed_users=failed_users) or []))
|
|
|
|
|
|
|
|
# Sync users
|
|
# Sync users
|
|
|
if sync_users:
|
|
if sync_users:
|
|
@@ -1304,21 +1312,26 @@ def _import_ldap_suboordinate_groups(connection, groupname_pattern, import_membe
|
|
|
# which are defined by 'uid'.
|
|
# which are defined by 'uid'.
|
|
|
user_info = None
|
|
user_info = None
|
|
|
try:
|
|
try:
|
|
|
- user_info = connection.find_users(posix_member, search_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(), user_name_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(), find_by_dn=False)
|
|
|
|
|
|
|
+ user_info = connection.find_users(posix_member, search_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(),
|
|
|
|
|
+ user_name_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(),
|
|
|
|
|
+ find_by_dn=False)
|
|
|
except LdapSearchException as e:
|
|
except LdapSearchException as e:
|
|
|
LOG.warn("Failed to find LDAP user: %s" % e)
|
|
LOG.warn("Failed to find LDAP user: %s" % e)
|
|
|
|
|
|
|
|
if user_info:
|
|
if user_info:
|
|
|
users = _import_ldap_users_info(connection, user_info, import_by_dn=False, failed_users=failed_users)
|
|
users = _import_ldap_users_info(connection, user_info, import_by_dn=False, failed_users=failed_users)
|
|
|
if users:
|
|
if users:
|
|
|
- LOG.debug("Adding member %s represented as users (should be a single user) %s to group %s" % (smart_str(posix_member), smart_str(users), smart_str(group.name)))
|
|
|
|
|
|
|
+ LOG.debug("Adding member %s represented as users (should be a single user) %s to group %s" % (
|
|
|
|
|
+ smart_str(posix_member), smart_str(users), smart_str(group.name)))
|
|
|
group.user_set.add(*users)
|
|
group.user_set.add(*users)
|
|
|
|
|
|
|
|
if sync_users:
|
|
if sync_users:
|
|
|
for posix_member in posix_members:
|
|
for posix_member in posix_members:
|
|
|
user_info = []
|
|
user_info = []
|
|
|
try:
|
|
try:
|
|
|
- user_info = connection.find_users(posix_member, search_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(), user_name_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(), find_by_dn=False)
|
|
|
|
|
|
|
+ user_info = connection.find_users(posix_member, search_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(),
|
|
|
|
|
+ user_name_attr=desktop.conf.LDAP.USERS.USER_NAME_ATTR.get(),
|
|
|
|
|
+ find_by_dn=False)
|
|
|
except LdapSearchException as e:
|
|
except LdapSearchException as e:
|
|
|
LOG.warn("Failed to find LDAP user: %s" % e)
|
|
LOG.warn("Failed to find LDAP user: %s" % e)
|
|
|
|
|
|
|
@@ -1369,4 +1382,4 @@ def _import_ldap_groups(connection, groupname_pattern, import_members=False, rec
|
|
|
|
|
|
|
|
|
|
|
|
|
def _get_failed_operation_text(username, operation):
|
|
def _get_failed_operation_text(username, operation):
|
|
|
- return '%(username)s is not allowed to perform %(operation)s' % {'username': username, 'operation': operation}
|
|
|
|
|
|
|
+ return '%(username)s is not allowed to perform %(operation)s' % {'username': username, 'operation': operation}
|