Skip to content

Commit 2fefba4

Browse files
authored
Merge pull request #56 from wp-graphql/revert-55-feature/wp-graphql-v0.6.0-support
Revert "Adds WPGraphQL v0.6.0 support"
2 parents 9158130 + a598d7a commit 2fefba4

File tree

4 files changed

+257
-173
lines changed

4 files changed

+257
-173
lines changed

src/Login.php

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,52 @@
11
<?php
2-
/**
3-
* Register the login mutation to the WPGraphQL Schema
4-
*
5-
* @package WPGraphQL\JWT_Authentication
6-
* @since 0.0.1
7-
*/
8-
92
namespace WPGraphQL\JWT_Authentication;
103

114
use GraphQL\Type\Definition\ResolveInfo;
125
use WPGraphQL\AppContext;
136

14-
/**
15-
* Class - Login
16-
*/
177
class Login {
8+
189
/**
19-
* Register the mutation.
10+
* Register the login mutation to the WPGraphQL Schema
2011
*/
2112
public static function register_mutation() {
22-
register_graphql_mutation(
23-
'login',
24-
[
25-
'description' => __( 'Login a user. Request for an authToken and User details in response', 'wp-graphql-jwt-authentication' ),
26-
'inputFields' => [
27-
'username' => [
28-
'type' => [ 'non_null' => 'String' ],
29-
'description' => __( 'The username used for login. Typically a unique or email address depending on specific configuration', 'wp-graphql-jwt-authentication' ),
30-
],
31-
'password' => [
32-
'type' => [ 'non_null' => 'String' ],
33-
'description' => __( 'The plain-text password for the user logging in.', 'wp-graphql-jwt-authentication' ),
34-
],
13+
14+
register_graphql_mutation( 'login', [
15+
'description' => __( 'Login a user. Request for an authToken and User details in response', 'wp-graphql-jwt-authentication' ),
16+
'inputFields' => [
17+
'username' => [
18+
'type' => [ 'non_null' => 'String' ],
19+
'description' => __( 'The username used for login. Typically a unique or email address depending on specific configuration', 'wp-graphql-jwt-authentication' ),
20+
],
21+
'password' => [
22+
'type' => [ 'non_null' => 'String' ],
23+
'description' => __( 'The plain-text password for the user logging in.', 'wp-graphql-jwt-authentication' ),
24+
],
25+
],
26+
'outputFields' => [
27+
'authToken' => [
28+
'type' => 'String',
29+
'description' => __( 'JWT Token that can be used in future requests for Authentication', 'wp-graphql-jwt-authentication' ),
3530
],
36-
'outputFields' => [
37-
'authToken' => [
38-
'type' => 'String',
39-
'description' => __( 'JWT Token that can be used in future requests for Authentication', 'wp-graphql-jwt-authentication' ),
40-
],
41-
'refreshToken' => [
42-
'type' => 'String',
43-
'description' => __( 'A JWT token that can be used in future requests to get a refreshed jwtAuthToken. If the refresh token used in a request is revoked or otherwise invalid, a valid Auth token will NOT be issued in the response headers.', 'wp-graphql-jwt-authentication' ),
44-
],
45-
'user' => [
46-
'type' => 'User',
47-
'description' => __( 'The user that was logged in', 'wp-graphql-jwt-authentication' ),
48-
],
31+
'refreshToken' => [
32+
'type' => 'String',
33+
'description' => __( 'A JWT token that can be used in future requests to get a refreshed jwtAuthToken. If the refresh token used in a request is revoked or otherwise invalid, a valid Auth token will NOT be issued in the response headers.', 'wp-graphql-jwt-authentication' ),
4934
],
50-
'mutateAndGetPayload' => function( $input, AppContext $context, ResolveInfo $info ) {
51-
// Login the user in and get an authToken and user in response.
52-
return Auth::login_and_get_token( sanitize_user( $input['username'] ), trim( $input['password'] ) );
53-
},
54-
]
55-
);
35+
'user' => [
36+
'type' => 'User',
37+
'description' => __( 'The user that was logged in', 'wp-graphql-jwt-authentication' ),
38+
],
39+
],
40+
'mutateAndGetPayload' => function( $input, AppContext $context, ResolveInfo $info ) {
41+
42+
/**
43+
* Login the user in and get an authToken and user in response
44+
*/
45+
return Auth::login_and_get_token( sanitize_user( $input['username'] ), trim( $input['password'] ) );
46+
47+
},
48+
]);
49+
5650
}
51+
5752
}

0 commit comments

Comments
 (0)