fix(admin): fix import user with csv with no group assigned

darta 2022-02-06 19:29:24 +01:00
parent 304d8e8724
commit cc8bdc8554
1 changed files with 12 additions and 11 deletions

View File

@ -584,8 +584,8 @@ class Admin:
+ ") uploaded user: " + ") uploaded user: "
+ u["username"] + u["username"]
) )
user_groups = [g.strip() for g in u["groups"].split(",")] user_groups = [g.strip() for g in u["groups"].split(",") if g !=""]
if not len(user_groups): user_groups = ["/"+u["role"].strip()]
pathslist = [] pathslist = []
for group in user_groups: for group in user_groups:
pathpart = "" pathpart = ""
@ -637,15 +637,16 @@ class Admin:
groups = list(dict.fromkeys(groups)) groups = list(dict.fromkeys(groups))
sysgroups = [] sysgroups = []
for g in groups: for g in groups:
sysgroups.append( if g != "":
{ sysgroups.append(
"provider": "external", {
"id": g, "provider": "external",
"name": kpath2gid(g), "id": g,
"path": g, "name": kpath2gid(g),
"description": "Imported with csv", "path": g,
} "description": "Imported with csv",
) }
)
self.external["groups"] = sysgroups self.external["groups"] = sysgroups
return True return True