Skip to content

Feature/7675 social login service call - #7872

Merged
aerych merged 18 commits into
developfrom
feature/7675-social-login-service-call
Oct 2, 2017
Merged

Feature/7675 social login service call#7872
aerych merged 18 commits into
developfrom
feature/7675-social-login-service-call

Conversation

@aerych

@aerych aerych commented Sep 28, 2017

Copy link
Copy Markdown
Contributor

Refs #7675
This PR adds the service and networking layer to support social login. It also wires up the google sign in button to test the simplest login scenario.

This PR does not address cases where:

  • there is no matching WPcom account,
  • an matching wpcom account is found but is not already connected,
  • 2fa is enabled.
    These cases will be addressed in subsequent PRs.

To test:
Use the Google sign in button to login to a WPcom account that has already been connected to a Google profile. Confirm you can login successfully in this scenario.

Confirm that the google button is correctly positioned on the iPad.

Needs review: @nheagy

@aerych
aerych requested a review from nheagy September 28, 2017 19:59
@aerych aerych added the Login label Sep 28, 2017
@aerych aerych added this to the 8.6 milestone Sep 28, 2017
let email = user.profile.email else {
// The Google SignIn for may have been canceled.
//TODO: Add analytis
return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Trailing Semicolon Violation: Lines should not have trailing semicolons. (trailing_semicolon)

@nheagy nheagy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems to be running well 👍

I've got some minor code changes requested, but nothing huge. Nice work 😀

- (void)loginToWordPressDotComWithGoogleIDToken:(NSString *)googleIDToken
{
if ([self.delegate respondsToSelector:@selector(displayLoginMessage:)]) {
[self.delegate displayLoginMessage:NSLocalizedString(@"Connecting to WordPress.com", nil)];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I know we already do this in -signInToWordpressDotCom but I don't really love having UI-surfaced strings in the networking code. If instead we told the delegate the state had changed, the VC could decide how to present it: string, icon, or otherwise. Think that's worth changing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not too much of a fan either. I still have the dream of nuking the facade completely, but until then I think we should be consistent.

@param success
@param failure
*/
- (void)connectToSocialService:(NSString *)service

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could this be an enum or at least a typedef instead of a string?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

A string enum would be perfect but... objc. :/ Maybe a typedef constant tho.

"id_token" : token,
] as [String : Any]

// Passes an empty string for the

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This comment is incomplete. Passes an empty string for the…

THE SUSPENSE 😂

import Foundation

@objc
public class SocialLogin2FANonceInfo: NSObject {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wish this could be a struct. shakes fist at Objective-C


// Make sure we received expected data.
guard let responseDictionary = responseObject as? [String: AnyObject],
let data = responseDictionary["data"] as? [String: AnyObject] else {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

data isn't very descriptive. responseData might be better?

@IBOutlet var bottomContentConstraint: NSLayoutConstraint?
@IBOutlet var verticalCenterConstraint: NSLayoutConstraint?
var onePasswordButton: UIButton!
var googleLoginButon: UIButton?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor thing, but this should have two ts in Buton 😉

@aerych

aerych commented Sep 30, 2017

Copy link
Copy Markdown
Contributor Author

Heya @nheagy. Thanks for the review. I've made some tweaks. For the typedef suggestion I've refactored the new methods into a Swift category so a string enum can be used.

Ready for another peek!

/// - token The service's OpenID Connect (JWT) ID token for the user.
/// - success
/// - failure
func connectToSocialService(_ service: SocialServiceName, serviceIDToken token:String, success:@escaping (() -> Void), failure:@escaping ((NSError) -> Void)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Colon Violation: Colons should be next to the identifier when specifying a type and next to the key in dictionary literals. (colon)

@nheagy nheagy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks great!

:shipit:

import Foundation
import WordPressComKit

extension AccountService {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Love this.

}


extension AccountServiceRemoteREST {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

love this, too

@aerych

aerych commented Oct 2, 2017

Copy link
Copy Markdown
Contributor Author

Thanks @nheagy !!

@aerych
aerych merged commit 44e6b59 into develop Oct 2, 2017
@aerych
aerych deleted the feature/7675-social-login-service-call branch October 2, 2017 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants