diff --git a/src/Auth.php b/src/Auth.php index c719813..b06702a 100644 --- a/src/Auth.php +++ b/src/Auth.php @@ -47,6 +47,14 @@ public static function login_and_get_token( $username, $password ) { throw new UserError( __( 'JWT Auth is not configured correctly. Please contact a site administrator.', 'wp-graphql-jwt-authentication' ) ); } + /** + * Do whatever you need before authenticating the user. + * + * @param string $username Username as sent by the user + * @param string $password Password as sent by the user + */ + do_action( 'graphql_jwt_auth_before_authenticate', $username, $password ); + /** * Authenticate the user and get the Authenticated user object in response */ @@ -76,7 +84,12 @@ public static function login_and_get_token( $username, $password ) { /** * Let the user modify the data before send it back + * + * @param \WP_User $user The authenticated user + * @param array $response The default response */ + $response = apply_filters( 'graphql_jwt_auth_after_authenticate', $user, $response ); + return ! empty( $response ) ? $response : []; }