Skip to content

Conversation

@TylerB24890
Copy link
Collaborator

@TylerB24890 TylerB24890 commented May 6, 2025

Description of the Change

  • Send the base /wp-json/jobber/v1 endpoint as the clientUrl to the middleware.
    • Allows us to store the root API endpoint and simply append /disconnect for the disconnect request.
  • Update all API endpoints to use a get_endpoint( $path ) method so the $url variable is the base API URL.
    • e.g. $refresh_endpoint = Jobber::get_endpoint( 'refresh' ); // middleware refresh URL
    • e.g. $disconnect_endpoint = Jobber::get_endpoint( 'disconnect' ); // middleware disconnect URL
    • e.g. $token_endpoint = Token::get_endpoint( 'generate' ); // WP token generate URL
    • e.g. $auth_endpoint = Token::get_endpoint( 'validate' ); // WP token validate URL
  • Send an additional tokenUrl parameter with the initial /auth request.
    • This will send the /token/generate URL for us to generate a client_token.
  • Create a /wp-json/jobber/v1/disconnect endpoint to handle Jobber > WP disconnects.
    • Middleware will send a POST request to this endpoint when a Jobber Webhook is received.
    • POST request will validate the jobber_token from the middleware and delete the DB records if successful.
  • Send a POST request to [middleware]/disconnect when the WP "Disconnect" button is clicked.
    • POST request will include the clientToken parameter.
    • Middleware will validate the clientToken with the disconnect parameter appended to the API endpoint.
    • The token validation will see this disconnect argument and run the disconnect_client() method on successul validation.
      • User is redirected to the settings page with the &jobber_disconnected=true parameter in the URL.
      • This will tell the UI to display the disconnected content (we need to do this because the middleware POST request may not be complete by time the page refreshes)

Closes #19

How to test the Change

Changelog Entry

Added - Disconnect Flow

Credits

Props @TylerB24890

Checklist:

@github-actions github-actions bot added the needs:code-review This requires code review. label May 6, 2025
@TylerB24890 TylerB24890 requested a review from dkotter May 6, 2025 18:52
dkotter
dkotter previously approved these changes May 13, 2025
Copy link
Collaborator

@dkotter dkotter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this in conjunction with the middleware PR that adds disconnect support and everything seems to be working great. For now, going to leave this unmerged as we've already submitted the plugin to WordPress.org for review. Will merge this in once that is approved and we're ready for public release.

@dkotter dkotter removed the needs:code-review This requires code review. label May 13, 2025
@dkotter dkotter added this to the 1.0.0 milestone May 13, 2025
@github-actions github-actions bot added the needs:refresh This requires a refreshed PR to resolve. label May 14, 2025
@github-actions github-actions bot added needs:code-review This requires code review. and removed needs:refresh This requires a refreshed PR to resolve. labels May 14, 2025
@dkotter dkotter merged commit cdc2e1b into develop May 14, 2025
6 of 7 checks passed
@dkotter dkotter deleted the feature/disconnect-flow branch May 14, 2025 16:59
@dkotter
Copy link
Collaborator

dkotter commented May 14, 2025

For now, going to leave this unmerged as we've already submitted the plugin to WordPress.org for review. Will merge this in once that is approved and we're ready for public release.

Since we needed to re-submit anyway to resolve a few issues, merged this in so it will be included as part of the initial review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:code-review This requires code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ability to disconnect your account

2 participants