Skip to content

Commit

Permalink
Merge 65e6079 into a315d5e
Browse files Browse the repository at this point in the history
  • Loading branch information
Benkimeric committed Jun 19, 2019
2 parents a315d5e + 65e6079 commit 1ab18fe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion authors/apps/articles/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def destroy(self, request, slug=None, *args, **kwargs):
try:
article = ArticleModel.objects.filter(slug=slug)[0]

if not article.author.id == request.user.id:
if not (article.author.id == request.user.id or request.user.is_superuser):
return Response({'status': 403, 'error': "You cannot delete an article you do not own"}, status=403)

self.perform_destroy(article)
Expand Down
2 changes: 2 additions & 0 deletions authors/apps/authentication/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,10 @@ def post(self, request):
serializer.is_valid(raise_exception=True)
user_data = User.objects.get(email=user['email'])
token = handle_token(user_data)
isAdmin = user_data.is_superuser
res = serializer.data
res['token'] = token
res['isAdmin'] = isAdmin

return Response(res, status=status.HTTP_200_OK)

Expand Down

0 comments on commit 1ab18fe

Please sign in to comment.