|
@@ -54,7 +54,8 @@ class UserType(graphene.ObjectType):
|
|
user = User.objects.get(_id = self._id)
|
|
user = User.objects.get(_id = self._id)
|
|
acl = ["anon"]
|
|
acl = ["anon"]
|
|
if user._id:
|
|
if user._id:
|
|
- acl.append("user")
|
|
|
|
|
|
+ if user.is_active:
|
|
|
|
+ acl.append("active")
|
|
if user.is_superuser:
|
|
if user.is_superuser:
|
|
acl.append("admin")
|
|
acl.append("admin")
|
|
|
|
|
|
@@ -145,6 +146,11 @@ class UserUpsert(graphene.Mutation):
|
|
def mutate(root,info,user):
|
|
def mutate(root,info,user):
|
|
new_user={}
|
|
new_user={}
|
|
ava = None
|
|
ava = None
|
|
|
|
+ acl = []
|
|
|
|
+
|
|
|
|
+ if "acl" in user:
|
|
|
|
+ acl = user.get("acl", [])
|
|
|
|
+ user.pop("acl")
|
|
|
|
|
|
if "avatar" in user:
|
|
if "avatar" in user:
|
|
if user.get("avatar") == "null":
|
|
if user.get("avatar") == "null":
|
|
@@ -187,6 +193,14 @@ class UserUpsert(graphene.Mutation):
|
|
else:
|
|
else:
|
|
new_user.avatar = ava
|
|
new_user.avatar = ava
|
|
|
|
|
|
|
|
+
|
|
|
|
+ if len(acl):
|
|
|
|
+ if not info.context.user.is_superuser:
|
|
|
|
+ raise Exception("Authentication credentials were not provided")
|
|
|
|
+
|
|
|
|
+ new_user.is_active = "active" in "acl"
|
|
|
|
+ new_user.is_admin = "admin" in "acl"
|
|
|
|
+
|
|
new_user.save()
|
|
new_user.save()
|
|
|
|
|
|
|
|
|