Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.

Replace GIDGoogleUser with SocialService.User in case .google#764

Merged
mokagio merged 4 commits into
trunkfrom
mokagio/social-service-without-google
Apr 3, 2023
Merged

Replace GIDGoogleUser with SocialService.User in case .google#764
mokagio merged 4 commits into
trunkfrom
mokagio/social-service-without-google

Conversation

@mokagio

@mokagio mokagio commented Mar 28, 2023

Copy link
Copy Markdown
Contributor

Closes #759.

As described in #759, the idea with this PR is to remove the Google SDK-dependent type from the SocialService google case associated value and use the pure Swift SocialService.User instead. The new type was introduced in #763.

To test

The code changes here are consumed via unit tests alone. The demo app doesn't read the loginFields metadata where SocialService lives.

The "real" test for this new code is in the Jetpack/WordPress iOS that uses it wordpress-mobile/WordPress-iOS#20128


  • I have considered if this change warrants release notes and have added them to the appropriate section in the CHANGELOG.md if necessary.

@mokagio mokagio force-pushed the mokagio/social-service-without-google branch from 72f663a to 26c8d44 Compare March 29, 2023 00:20
Base automatically changed from mokagio/read-name-from-id-token to trunk March 29, 2023 11:08
@mokagio mokagio force-pushed the mokagio/social-service-without-google branch from 26c8d44 to a78ed0d Compare March 29, 2023 11:20
Comment on lines +12 to +21
public var user: User {
switch self {
case .google(let user): return user
case .apple(let user): return user
}
}

/// Google's Signup Linked Account
///
case google(user: GIDGoogleUser)
case google(user: User)

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.

apple and google both have a User associated type now.

This kind of makes it backward to have an enum with associated type, we should have a type with an enum property

struct SocialUser {

  let fullName: String
  let email: String
  let source: SocialUser.Source // .apple, .google, ...
}

I've come across other bits of information in some places that could go into this type, such as the token.

I'm skeptical of working on "such a big" rewrite, though. We should be making changes to the auth layer here carefully. Also, I'd like to first remove all the Google-SDK cruft first. The downside is that we'll have to go through at least two major versions. I think it's worth it, though.

Comment on lines 166 to 169
socialService: SocialServiceName? = nil,
socialServiceIDToken: String? = nil,
googleUser: GIDGoogleUser? = nil,
googleUser: SocialService.User? = nil,
appleUser: SocialService.User? = nil) {

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 wrote it elsewhere already, but it seems to me like these parameters are ripe for consolidation into a single type (SocialUser?).

I'm not keen on introducing such a change right now because I'd like to stay focused on removing the Google SDK only. The tradeoff is that we'll have to cycle through two major version changes, but that seems acceptable. It's just a number after all.

@mokagio mokagio Mar 30, 2023

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 wrote it elsewhere

Elsewhere = the file after this, 14 hours ago 🤦‍♂️ 🙃

But hey, at least I'm consistent in the naming suggestion I'm leaving...

@mokagio mokagio requested review from crazytonyli and jaclync March 30, 2023 11:51
@mokagio mokagio marked this pull request as ready for review March 30, 2023 11:51
)
}

func updateLoginFields(email: String, username: String, fullName: String, googleToken: String) {

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 username argument is not used, should we get rid of it? Also, any reason adding another updateLoginFields function here, rather than do the assignments in the one above?

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.

What I should have done with that username parameter was using it in the method and then passing .email at callsite. I guess I was trying to cover my basis.

But your observation made me realize the version with the GIDGoogleUser input is unused, and this new one is only used by it. So, I removed both of them.

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.

Yay, more deletions!

@mokagio mokagio merged commit 87942d9 into trunk Apr 3, 2023
@mokagio mokagio deleted the mokagio/social-service-without-google branch April 3, 2023 00:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Google sign in without SDK – New accounts lack email in WPAccount

2 participants