mirror of https://github.com/veops/cmdb.git
Dev api 240328 (#445)
* feat(api): login api supports parameter auth_with_ldap * fix(api): transfer attribute
This commit is contained in:
parent
472642c958
commit
614766563e
|
@ -699,6 +699,10 @@ class CITypeAttributeManager(object):
|
||||||
to_group = CITypeAttributeGroup.get_by(type_id=type_id, name=to_group_name, first=True, to_dict=False)
|
to_group = CITypeAttributeGroup.get_by(type_id=type_id, name=to_group_name, first=True, to_dict=False)
|
||||||
to_group_id = to_group and to_group.id
|
to_group_id = to_group and to_group.id
|
||||||
|
|
||||||
|
if not to_group_id and CITypeInheritance.get_by(child_id=type_id, to_dict=False):
|
||||||
|
to_group = CITypeAttributeGroup.create(type_id=type_id, name=to_group_name)
|
||||||
|
to_group_id = to_group and to_group.id
|
||||||
|
|
||||||
if from_group_id != to_group_id:
|
if from_group_id != to_group_id:
|
||||||
if from_group_id is not None:
|
if from_group_id is not None:
|
||||||
CITypeAttributeGroupManager.delete_item(from_group_id, attr_id)
|
CITypeAttributeGroupManager.delete_item(from_group_id, attr_id)
|
||||||
|
|
|
@ -66,7 +66,7 @@ class Search(object):
|
||||||
self.has_m2m = True
|
self.has_m2m = True
|
||||||
|
|
||||||
self.type2filter_perms = None
|
self.type2filter_perms = None
|
||||||
|
|
||||||
self.is_app_admin = is_app_admin('cmdb') or current_user.username == "worker"
|
self.is_app_admin = is_app_admin('cmdb') or current_user.username == "worker"
|
||||||
|
|
||||||
def _get_ids(self, ids):
|
def _get_ids(self, ids):
|
||||||
|
@ -320,7 +320,8 @@ class Search(object):
|
||||||
else:
|
else:
|
||||||
__tmp = []
|
__tmp = []
|
||||||
|
|
||||||
_tmp[idx] = [j for i in __tmp for j in i]
|
if __tmp:
|
||||||
|
_tmp[idx] = [j for i in __tmp for j in i]
|
||||||
else:
|
else:
|
||||||
_tmp[idx] = []
|
_tmp[idx] = []
|
||||||
level2ids[lv].append([])
|
level2ids[lv].append([])
|
||||||
|
|
|
@ -38,8 +38,9 @@ class LoginView(APIView):
|
||||||
username = request.values.get("username") or request.values.get("email")
|
username = request.values.get("username") or request.values.get("email")
|
||||||
password = request.values.get("password")
|
password = request.values.get("password")
|
||||||
_role = None
|
_role = None
|
||||||
|
auth_with_ldap = request.values.get('auth_with_ldap', True)
|
||||||
config = AuthenticateDataCRUD(AuthenticateType.LDAP).get()
|
config = AuthenticateDataCRUD(AuthenticateType.LDAP).get()
|
||||||
if config.get('enabled') or config.get('enable'):
|
if (config.get('enabled') or config.get('enable')) and auth_with_ldap:
|
||||||
from api.lib.perm.authentication.ldap import authenticate_with_ldap
|
from api.lib.perm.authentication.ldap import authenticate_with_ldap
|
||||||
user, authenticated = authenticate_with_ldap(username, password)
|
user, authenticated = authenticate_with_ldap(username, password)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue