[Update] 修改小问题 (#2100)

* [Update] 不修改admin用户的用户来源

* [Bugfix] 修复Default组织下用户列表会显示所有用户,并查看详情会报错

* [Update] 关闭telnet资产测试可连接性

* [Update] 只有ssh协议资产可测试连接性
pull/2102/head^2
BaiJiangJie 6 years ago committed by 老广
parent 060248d1ca
commit f380d82b55

@ -159,7 +159,7 @@
</span> </span>
</td> </td>
</tr> </tr>
{% if asset.is_unixlike %} {% if asset.protocol == 'ssh' %}
<tr> <tr>
<td>{% trans 'Refresh hardware' %}:</td> <td>{% trans 'Refresh hardware' %}:</td>
<td> <td>

@ -1,7 +1,8 @@
from django.http.request import QueryDict from django.http.request import QueryDict
from django.contrib.auth.signals import user_logged_out
from django.dispatch import receiver
from django.conf import settings from django.conf import settings
from django.dispatch import receiver
from django.contrib.auth.signals import user_logged_out
from django_auth_ldap.backend import populate_user
from .openid import client from .openid import client
from .signals import post_create_openid_user from .signals import post_create_openid_user
@ -31,3 +32,9 @@ def on_post_create_openid_user(sender, user=None, **kwargs):
user.source = user.SOURCE_OPENID user.source = user.SOURCE_OPENID
user.save() user.save()
@receiver(populate_user)
def on_ldap_create_user(sender, user, ldap_user, **kwargs):
if user and user.name != 'admin':
user.source = user.SOURCE_LDAP
user.save()

@ -39,7 +39,7 @@ class UserViewSet(IDInFilterMixin, BulkModelViewSet):
def get_queryset(self): def get_queryset(self):
queryset = super().get_queryset() queryset = super().get_queryset()
if current_org.is_real(): if current_org.is_real() or current_org.is_default():
org_users = current_org.get_org_users() org_users = current_org.get_org_users()
queryset = queryset.filter(id__in=org_users) queryset = queryset.filter(id__in=org_users)
return queryset return queryset

@ -2,7 +2,6 @@
# #
from django.dispatch import receiver from django.dispatch import receiver
from django_auth_ldap.backend import populate_user
# from django.db.models.signals import post_save # from django.db.models.signals import post_save
from common.utils import get_logger from common.utils import get_logger
@ -30,9 +29,3 @@ def on_user_create(sender, user=None, **kwargs):
if user.email: if user.email:
send_user_created_mail(user) send_user_created_mail(user)
@receiver(populate_user)
def on_ldap_create_user(sender, user, ldap_user, **kwargs):
if user:
user.source = user.SOURCE_LDAP
user.save()

Loading…
Cancel
Save