Skip to content
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

Enable wordpress.com Oath2 support #58

Merged
merged 44 commits into from
Feb 13, 2018

Conversation

adamsilverstein
Copy link

POC for review.

  • Add a new WordPressDotcomOauth2Authentication authentication type that supports posting to sites hosted on the .com infrastructure.
  • Add some UI manipulation to show the correct form fields on the add/edit external connection screen. Since OAuth requires several steps, and also requires a redirect URL (with a post id), we hide all fields initially so the connection is saved, then we show the two required connection fields: ID and secret. Finally, when a token has been retrieved and the connection is authenticated, we show the remaining connection options.

@tomjn
Copy link
Contributor

tomjn commented Jan 29, 2018

Looks good from a reading of the code, but I haven't tested

var hideItemsRequiringAuth = function() {
oauthconnectionestablished = document.getElementsByClassName( 'oauth-connection-established' );
if ( 0 === oauthconnectionestablished.length ) {
$( '.hide-until-authed' ).hide();
Copy link
Member

Choose a reason for hiding this comment

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

Can we cache this selector?

Copy link
Author

Choose a reason for hiding this comment

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

yep, done

$( externalConnectionTypeField ).on( 'change', function( event ) {
var slug = externalConnectionTypeField.value;

$( '.auth-credentials' ).hide();
Copy link
Member

Choose a reason for hiding this comment

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

Can we cache this selector?

Copy link
Author

Choose a reason for hiding this comment

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

yep

$( changeCredentials ).on( 'click', function() {

// Show the credentials fields.
$( '.oauth-authentication-details-wrapper' ).show();
Copy link
Member

Choose a reason for hiding this comment

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

Can we cache this selector?

Copy link
Author

Choose a reason for hiding this comment

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

done


// Handle click to the wpdotcom begin-authorization button.
$( beginAuthorize ).on( 'click', function( event ) {
var $titleEl = $( document.getElementById( 'title' ) ),
Copy link
Member

Choose a reason for hiding this comment

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

There is already a selector for this

Copy link
Author

Choose a reason for hiding this comment

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

used that now

*
* @param string $error_message The error message to log.
*/
public static function log_authentication_error( $error_message ) {
Copy link
Member

Choose a reason for hiding this comment

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

I like this

Copy link
Author

Choose a reason for hiding this comment

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

👍

@@ -312,15 +312,15 @@ public function push( $post_id, $args = array() ) {

if ( function_exists( 'vip_safe_wp_remote_get' ) ) {
$response = vip_safe_wp_remote_get(
$types_path, $this->auth_handler->format_get_args( array(
Copy link
Member

Choose a reason for hiding this comment

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

Why remove this?

Copy link
Author

Choose a reason for hiding this comment

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

hmm, i think that is a mistake, will restore

Copy link
Author

Choose a reason for hiding this comment

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

Fixed in f24fe0b

@tlovett1
Copy link
Member

tlovett1 commented Feb 6, 2018

@adamsilverstein here's my latest round of QA:

  • Duplicate external connection created
  • Step 1
    • Button should say “Start Setup”
  • Step 2
    • No error message for bad credentials
  • Step 3
    • Need space after checkmark
    • Clicked change connections, clicked Authorize Connection with empty secret, next screen says authorization was successful

Copy link
Contributor

@tomjn tomjn left a comment

Choose a reason for hiding this comment

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

Things look alright, aside from merge conflicts, what else is needed at your end? Or is this pretty much done?

@adamsilverstein
Copy link
Author

@tomjn Thanks... Yes, we have completed our internal review as well, and I will go ahead and get this merged. My next planned step is to commit the plugin with a client theme for a complete review; I will reference this pull request on the commit.

Adam Silverstein added 4 commits February 13, 2018 08:18
# Conflicts:
#	assets/css/sass/admin-external-connection.scss
#	assets/js/src/admin-external-connection.js
#	includes/classes/ExternalConnections/WordPressExternalConnection.php
@adamsilverstein adamsilverstein merged commit fccef78 into master Feb 13, 2018
@tlovett1 tlovett1 deleted the feature/enable-wordpressdotcom-oath2-auth branch April 10, 2018 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants