Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a62675b

Browse files
feat(authentiction): Add admin user
1 parent f96479e commit a62675b

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

‎users/schema.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@ class Query(graphene.ObjectType):
1515
users = graphene.List(UserType)
1616

1717
def resolve_users(self, info):
18+
user = info.context.user
19+
if not user.is_superuser:
20+
raise Exception('Not authorized to view this')
21+
1822
return get_user_model().objects.all()
1923

2024
def resolve_me(self, info):
2125
user = info.context.user
22-
if user.is_anonymous:
23-
raise Exception('User not logged!')
26+
if notuser.is_authenticated:
27+
return Exception('Authentication credentials were not provided')
2428

2529
return user
2630

‎users/schema_relay.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from graphene import relay
55
from django.contrib.auth import get_user_model
66
from graphene_django import DjangoObjectType
7-
87
from graphene_django.filter import DjangoFilterConnectionField
98

109

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /