Skip to content

Conversation

@faisal-alvi
Copy link
Contributor

@faisal-alvi faisal-alvi commented Apr 23, 2025

Description of the Change

This PR adds disconnect functionality to the Jobber integration, allowing users to disconnect their Jobber account from WordPress. The implementation includes:

  1. A new Disconnect class that handles both UI-initiated and middleware-initiated disconnects
  2. A REST endpoint at /wp-json/jobber/v1/disconnect for the middleware to call
  3. Security measures including admin capability checks and nonce verification
  4. Proper cleanup of stored data through a shared delete_stored_data() method
  5. Integration with the existing module initialization system

The disconnect functionality can be triggered in two ways:

  • Through the WordPress admin UI (Settings > Jobber Forms)
  • Via a REST API call from the middleware (to be implemented)

Note:
Once the middleware is ready, this will be extended to also trigger a request to the middleware to handle the disconnection flow completely.

Closes #19

How to test the Change

  1. Install and activate the plugin
  2. Navigate to Settings > Jobber Forms
  3. Connect your Jobber account
  4. Verify the disconnect button appears
  5. Click disconnect and confirm
  6. Verify the connection is removed and settings are cleared
  7. Verify any embedded forms no longer render

Changelog Entry

Added - Disconnect functionality for Jobber integration

Credits

Props @dkotter @faisal-alvi

Checklist:

@faisal-alvi faisal-alvi requested a review from dkotter April 23, 2025 16:29
@github-actions github-actions bot added the needs:refresh This requires a refreshed PR to resolve. label Apr 23, 2025
@github-actions github-actions bot removed the needs:refresh This requires a refreshed PR to resolve. label Apr 23, 2025
@faisal-alvi
Copy link
Contributor Author

@TylerB24890 Just a heads up: this PR introduces a REST endpoint at /jobber/v1/disconnect. Calling this from the middleware will delete all Jobber data stored in the WordPress DB, including the access token, effectively disconnecting WordPress from Jobber.

register_rest_route(
'jobber/v1',
'/disconnect',
[
'methods' => WP_REST_Server::CREATABLE,
'callback' => [ $this, 'handle_rest_disconnect' ],
'permission_callback' => [ $this, 'verify_middleware_request' ],
]
);

@faisal-alvi faisal-alvi added this to the 1.0.0 milestone Apr 23, 2025
@github-actions github-actions bot added the needs:refresh This requires a refreshed PR to resolve. label Apr 29, 2025
@github-actions github-actions bot removed the needs:refresh This requires a refreshed PR to resolve. label Apr 29, 2025
@dkotter
Copy link
Collaborator

dkotter commented Apr 29, 2025

Note I've removed the REST API integration for now, as we'll need to support this in the middleware first and that may not be ready by the time we submit this to WordPress.org, so removed that and we can come back to that later. For reference when we need this again, removed that in d180247

@dkotter dkotter marked this pull request as ready for review April 29, 2025 16:25
@github-actions github-actions bot added the needs:code-review This requires code review. label Apr 29, 2025
@dkotter dkotter merged commit 90e7862 into develop Apr 29, 2025
8 checks passed
@dkotter dkotter deleted the feature/disconnect-flow branch April 29, 2025 16:36
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