Skip to content

Commit 1addb37

Browse files
committed
Added the action graphql_jwt_auth_before_authenticate and the filter graphql_jwt_auth_after_authenticate to hook before and after the authentication process
1 parent 6f4c18a commit 1addb37

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Auth.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ public static function login_and_get_token( $username, $password ) {
4747
throw new UserError( __( 'JWT Auth is not configured correctly. Please contact a site administrator.', 'wp-graphql-jwt-authentication' ) );
4848
}
4949

50+
/**
51+
* Do whatever you need before authenticating the user.
52+
*
53+
* @param string $username Username as sent by the user
54+
* @param string $password Password as sent by the user
55+
*/
56+
do_action( 'graphql_jwt_auth_before_authenticate', $username, $password );
57+
5058
/**
5159
* Authenticate the user and get the Authenticated user object in response
5260
*/
@@ -76,7 +84,12 @@ public static function login_and_get_token( $username, $password ) {
7684

7785
/**
7886
* Let the user modify the data before send it back
87+
*
88+
* @param \WP_User $user The authenticated user
89+
* @param array $response The default response
7990
*/
91+
$response = apply_filters( 'graphql_jwt_auth_after_authenticate', $user, $response );
92+
8093
return ! empty( $response ) ? $response : [];
8194
}
8295

0 commit comments

Comments
 (0)