-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LICENS-45 Add auth logic #16
Open
MlKilderkin
wants to merge
17
commits into
main
Choose a base branch
from
feature/LICENS-45/auth
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
25c7909
LICENS-45 Add auth logic
MlKilderkin f97b940
LICENS-45 Add link to upgrade notices
MlKilderkin c9da919
LICENS-45 Add link to upgrade notices
MlKilderkin d457408
LICENS-45 Add link to upgrade notices
MlKilderkin 2bf67dc
LICENS-45 Decode response
MlKilderkin 71c61bc
LICENS-45 Add url encode for params
MlKilderkin 772ddfb
LICENS-45 Fix issues with PHPStan
MlKilderkin 232bc45
LICENS-45 Add tests
MlKilderkin 6eaa2f7
LICENS-45 ignore phpstan
MlKilderkin e0c3a89
LICENS-45 Resolve CR comments
MlKilderkin 3ab0da2
LICENS-45 Resolve CR comments
MlKilderkin 9427972
LICENS-45 Fix tests
MlKilderkin 6091a4e
LICENS-45 Resovle comments
MlKilderkin 90b2bff
LICENS-45 Fix tests
MlKilderkin 0693a93
LICENS-45 Resolve CR comments
MlKilderkin 1f293c6
Update tests/wpunit/Resources/ResourceTest.php
MlKilderkin 4298871
Update tests/wpunit/Site/DataTest.php
MlKilderkin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
LICENS-45 Resovle comments
- Loading branch information
commit 6091a4ed341d7260ab075a19f8e91298a9a582fc
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,17 +13,27 @@ class Actions { | |
const QUERY_VAR = 'stellarwp_action'; | ||
|
||
/** | ||
* Register handle route for connect/disconnect | ||
* | ||
* @since 1.0.1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @borkweb how do we want to handle /**
* Some really awesome method.
*
* @since TBD
*
* @return void
*/ |
||
* | ||
* @return void | ||
* | ||
* @action init | ||
*/ | ||
public function register_route() { | ||
add_rewrite_endpoint( 'stellarwp', EP_ROOT, self::QUERY_VAR ); | ||
} | ||
|
||
/** | ||
* Handle auth connect and disconnect request | ||
* | ||
* @since 1.0.1 | ||
* | ||
* @param \WP $wp | ||
* | ||
* @return void | ||
* | ||
* @action parse_request | ||
*/ | ||
public function handle_auth_request( $wp ) { | ||
|
@@ -41,7 +51,9 @@ public function handle_auth_request( $wp ) { | |
} | ||
|
||
/** | ||
* Remove auth tokens | ||
* Remove auth tokens and redirect back to settings page | ||
* | ||
* @since 1.0.1 | ||
*/ | ||
public function handle_disconnect() { | ||
$license = $this->get_license_object(); | ||
|
@@ -56,6 +68,13 @@ public function handle_disconnect() { | |
exit(); | ||
} | ||
|
||
/** | ||
* Save auth token and redirect back to referer URL | ||
* | ||
* @since 1.0.1 | ||
* | ||
* @param array $args | ||
*/ | ||
public function handle_connect( $args ) { | ||
if ( empty( $args['token'] ) ) { | ||
$url = $this->get_origin_url(); | ||
|
@@ -83,6 +102,13 @@ public function handle_connect( $args ) { | |
exit(); | ||
} | ||
|
||
/** | ||
* Retrieve origin URL from server | ||
* | ||
* @since 1.0.1 | ||
* | ||
* @return string | ||
*/ | ||
protected function get_origin_url() { | ||
$license = $this->get_license_object(); | ||
$api = Config::get_container()->get( API\Client::class ); | ||
|
@@ -95,6 +121,13 @@ protected function get_origin_url() { | |
return ''; | ||
} | ||
|
||
/** | ||
* Retrieve License | ||
* | ||
* @since 1.0.1 | ||
* | ||
* @return mixed | ||
*/ | ||
protected function get_license_object() { | ||
$collection = Config::get_container()->get( Collection::class ); | ||
$plugin = $collection->current(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is hard to understand what's going on. I'm not sure I understand why the
Namespaces
class is necessary?