Logout user, move code
This commit is contained in:
parent
a9e7325b86
commit
a7ff7c2697
|
|
@ -10,8 +10,7 @@ from assignments.schema.queries import AssignmentsQuery, StudentSubmissionQuery
|
|||
from basicknowledge.queries import BasicKnowledgeQuery
|
||||
from books.schema.mutations import BookMutations
|
||||
from books.schema.queries import BookQuery
|
||||
from oauth.mutations import CouponMutations
|
||||
from core.schema.mutations.main import CoreMutations
|
||||
from oauth.mutations import OauthMutations
|
||||
from notes.mutations import NoteMutations
|
||||
from objectives.mutations import ObjectiveMutations
|
||||
from objectives.schema import ObjectivesQuery
|
||||
|
|
@ -34,9 +33,9 @@ class CustomQuery(UsersQuery, AllUsersQuery, ModuleRoomsQuery, RoomsQuery, Objec
|
|||
debug = graphene.Field(DjangoDebug, name='_debug')
|
||||
|
||||
|
||||
class CustomMutation(BookMutations, RoomMutations, AssignmentMutations, ObjectiveMutations, CoreMutations, PortfolioMutations,
|
||||
ProfileMutations, SurveyMutations, NoteMutations, SpellCheckMutations,
|
||||
CouponMutations, graphene.ObjectType):
|
||||
class CustomMutation(BookMutations, RoomMutations, AssignmentMutations, ObjectiveMutations, OauthMutations,
|
||||
PortfolioMutations, ProfileMutations, SurveyMutations, NoteMutations, SpellCheckMutations,
|
||||
graphene.ObjectType):
|
||||
if settings.DEBUG:
|
||||
debug = graphene.Field(DjangoDebug, name='_debug')
|
||||
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# ITerativ GmbH
|
||||
# http://www.iterativ.ch/
|
||||
#
|
||||
# Copyright (c) 2018 ITerativ GmbH. All rights reserved.
|
||||
#
|
||||
# Created on 22.10.18
|
||||
# @author: chrigu <christian.cueni@iterativ.ch>
|
||||
|
||||
import graphene
|
||||
from django.contrib.auth import logout
|
||||
|
||||
|
||||
class Logout(graphene.Mutation):
|
||||
success = graphene.Boolean()
|
||||
|
||||
def mutate(self, info, **kwargs):
|
||||
try:
|
||||
logout(info.context)
|
||||
return Logout(success=True)
|
||||
except Exception:
|
||||
return Logout(success=False)
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
from oauth.mutations import Coupon
|
||||
from core.schema.mutations.logout import Logout
|
||||
|
||||
|
||||
class CoreMutations(object):
|
||||
logout = Logout.Field()
|
||||
coupon = Coupon.Field()
|
||||
|
|
@ -57,6 +57,11 @@ class HepClient:
|
|||
response = self._call('api/auth/user', request, token)
|
||||
return response.json()['data']
|
||||
|
||||
def logout(self, request=None, token=None):
|
||||
self._has_credentials(request, token)
|
||||
response = self._call('api/auth/logout', request, token, method='post')
|
||||
return response.json()['message']
|
||||
|
||||
def fetch_eorders(self, request=None, token=None):
|
||||
# self._has_credentials(request, token)
|
||||
# data = {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import graphene
|
||||
from django.contrib.auth import logout
|
||||
from django.utils.timezone import now
|
||||
from graphene import relay
|
||||
|
||||
|
|
@ -47,3 +48,22 @@ class Coupon(relay.ClientIDMutation):
|
|||
|
||||
class CouponMutations:
|
||||
redeem_coupon = Coupon.Field()
|
||||
|
||||
|
||||
class Logout(graphene.Mutation):
|
||||
success = graphene.Boolean()
|
||||
|
||||
def mutate(self, info):
|
||||
try:
|
||||
logout(info.context)
|
||||
hep_client = HepClient()
|
||||
hep_client.logout(request=info)
|
||||
return Logout(success=True)
|
||||
except Exception:
|
||||
return Logout(success=False)
|
||||
|
||||
|
||||
class OauthMutations(object):
|
||||
logout = Logout.Field()
|
||||
coupon = Coupon.Field()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue