-
Notifications
You must be signed in to change notification settings - Fork 96
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
Fix Migration Token Generation; Add JSON Content-Type header #617
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b057079
Fix migration token incorrectly being generated
joshcanhelp e152006
Add JSON Content-Type header for Auth0 endpoints
joshcanhelp e7243b2
Add failing test for migration_token
joshcanhelp 7458714
Adjust migration_token setting to avoid deletion
joshcanhelp 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,6 +77,7 @@ public function custom_requests( $wp, $return = false ) { | |
return false; | ||
} | ||
|
||
$json_header = true; | ||
switch ( $page ) { | ||
case 'oauth2-config': | ||
$output = wp_json_encode( $this->oauth2_config() ); | ||
|
@@ -88,7 +89,8 @@ public function custom_requests( $wp, $return = false ) { | |
$output = wp_json_encode( $this->migration_ws_get_user() ); | ||
break; | ||
case 'coo-fallback': | ||
$output = $this->coo_fallback(); | ||
$json_header = false; | ||
$output = $this->coo_fallback(); | ||
break; | ||
default: | ||
return false; | ||
|
@@ -98,10 +100,27 @@ public function custom_requests( $wp, $return = false ) { | |
return $output; | ||
} | ||
|
||
if ( $json_header ) { | ||
add_filter( 'wp_headers', array( $this, 'add_json_header' ) ); | ||
$wp->send_headers(); | ||
} | ||
|
||
echo $output; | ||
exit; | ||
} | ||
|
||
/** | ||
* Use with the wp_headers filter to add a Content-Type header for JSON output. | ||
* | ||
* @param array $headers - Existing headers to modify. | ||
* | ||
* @return mixed | ||
*/ | ||
public function add_json_header( array $headers ) { | ||
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. Needs to be |
||
$headers['Content-Type'] = 'application/json; charset=' . get_bloginfo( 'charset' ); | ||
return $headers; | ||
} | ||
|
||
protected function coo_fallback() { | ||
$protocol = $this->a0_options->get( 'force_https_callback', false ) ? 'https' : null; | ||
return sprintf( | ||
|
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
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. Renaming test suite |
||
/** | ||
* Contains Class TestAdvancedOptionsValidation. | ||
* Contains Class TestOptionLoginRedirect. | ||
* | ||
* @package WP-Auth0 | ||
* | ||
|
@@ -10,10 +10,10 @@ | |
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Class TestAdvancedOptionsValidation. | ||
* Class TestOptionLoginRedirect. | ||
* Tests that Advanced settings are validated properly. | ||
*/ | ||
class TestAdvancedOptionsValidation extends TestCase { | ||
class TestOptionLoginRedirect extends TestCase { | ||
|
||
use setUpTestDb { | ||
setUp as setUpDb; | ||
|
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.
is this OK here or should it go before the
if ($return)
above ?? Maybe thesend_headers()
function might need to be called as well and you missed that (I don't really know)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.
No need for a header if we're just spitting back the data rather than outputting.