File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace ProcessWire \GraphQL \Field \Auth ;
4+
5+ use Youshido \GraphQL \Field \AbstractField ;
6+ use Youshido \GraphQL \Config \Field \FieldConfig ;
7+ use Youshido \GraphQL \Type \NonNullType ;
8+ use Youshido \GraphQL \Execution \ResolveInfo ;
9+ use ProcessWire \GraphQL \Type \Object \AuthResponseType ;
10+ use ProcessWire \WireData ;
11+ use ProcessWire \Session ;
12+
13+ class LogoutField extends AbstractField {
14+
15+ public function getType ()
16+ {
17+ return new NonNullType (new AuthResponseType ());
18+ }
19+
20+ public function getName ()
21+ {
22+ return 'logout ' ;
23+ }
24+
25+ public function getDescription ()
26+ {
27+ return 'Allows you to logout from the app. ' ;
28+ }
29+
30+ public function resolve ($ value , array $ args , ResolveInfo $ info )
31+ {
32+ $ session = \ProcessWire \wire ('session ' );
33+ $ session = $ session ->logout ();
34+ $ response = new WireData ();
35+ if ($ session instanceof Session) {
36+ $ response ->statusCode = 200 ;
37+ $ response ->message = 'Successful logout! ' ;
38+ } else {
39+ $ response ->statusCode = 500 ;
40+ $ response ->message = 'Could not logout. ' ;
41+ }
42+ return $ response ;
43+ }
44+
45+ }
You can’t perform that action at this time.
0 commit comments