Skip to content

Commit

Permalink
Add support for Google SignIn without SDK (#20128)
Browse files Browse the repository at this point in the history
  • Loading branch information
mokagio authored Apr 3, 2023
2 parents f03f594 + 3fee26b commit 4085c5b
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ abstract_target 'Apps' do

pod 'Gridicons', '~> 1.1.0'

pod 'WordPressAuthenticator', '~> 5.6-beta'
# pod 'WordPressAuthenticator', git: 'https://github.com/wordpress-mobile/WordPressAuthenticator-iOS.git', branch: 'trunk'
pod 'WordPressAuthenticator', '~> 6.0-beta'
# pod 'WordPressAuthenticator', git: 'https://github.com/wordpress-mobile/WordPressAuthenticator-iOS.git', branch: ''
# pod 'WordPressAuthenticator', git: 'https://github.com/wordpress-mobile/WordPressAuthenticator-iOS.git', commit: ''
# pod 'WordPressAuthenticator', path: '../WordPressAuthenticator-iOS'

Expand Down
14 changes: 7 additions & 7 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ PODS:
- WordPress-Aztec-iOS (1.19.8)
- WordPress-Editor-iOS (1.19.8):
- WordPress-Aztec-iOS (= 1.19.8)
- WordPressAuthenticator (5.7.0):
- WordPressAuthenticator (6.0.0):
- GoogleSignIn (~> 6.0.1)
- Gridicons (~> 1.0)
- "NSURL+IDN (= 0.4)"
Expand Down Expand Up @@ -611,7 +611,7 @@ DEPENDENCIES:
- SVProgressHUD (= 2.2.5)
- SwiftLint (~> 0.50)
- WordPress-Editor-iOS (~> 1.19.8)
- WordPressAuthenticator (~> 5.6-beta)
- WordPressAuthenticator (~> 6.0-beta)
- WordPressKit (~> 7.0.0-beta)
- WordPressShared (~> 2.0-beta)
- WordPressUI (~> 1.12.5)
Expand All @@ -622,7 +622,7 @@ DEPENDENCIES:

SPEC REPOS:
https://github.com/wordpress-mobile/cocoapods-specs.git:
- WordPressAuthenticator
- WordPressShared
trunk:
- Alamofire
- AlamofireImage
Expand Down Expand Up @@ -660,8 +660,8 @@ SPEC REPOS:
- UIDeviceIdentifier
- WordPress-Aztec-iOS
- WordPress-Editor-iOS
- WordPressAuthenticator
- WordPressKit
- WordPressShared
- WordPressUI
- WPMediaPicker
- wpxmlrpc
Expand Down Expand Up @@ -880,9 +880,9 @@ SPEC CHECKSUMS:
UIDeviceIdentifier: e6a801d25f4f178de5bdf475ffe29050d0148176
WordPress-Aztec-iOS: 7d11d598f14c82c727c08b56bd35fbeb7dafb504
WordPress-Editor-iOS: 9eb9f12f21a5209cb837908d81ffe1e31cb27345
WordPressAuthenticator: fc22569ef113e728823418120014725a7fdee8df
WordPressAuthenticator: b93b797eae278f7cda42693a652329173f1d5423
WordPressKit: a161c49306369cfa22c648866cee5aba16d7cbac
WordPressShared: 0aa459e5257a77184db87805a998f447443c9706
WordPressShared: 8e59bc8cec256f54a7c4cc6c94911adc2a9a65d2
WordPressUI: c5be816f6c7b3392224ac21de9e521e89fa108ac
WPMediaPicker: 0d45dfd7b3c5651c5236ffd48c1b0b2f60a2d5d2
wpxmlrpc: 68db063041e85d186db21f674adf08d9c70627fd
Expand All @@ -896,6 +896,6 @@ SPEC CHECKSUMS:
ZendeskSupportSDK: 3a8e508ab1d9dd22dc038df6c694466414e037ba
ZIPFoundation: ae5b4b813d216d3bf0a148773267fff14bd51d37

PODFILE CHECKSUM: 63504603fd92b4077b1a9556356336a69e571422
PODFILE CHECKSUM: e8074cd059cc2018e1e491754ebaa6d098c5432e

COCOAPODS: 1.11.3
2 changes: 2 additions & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* [**] [internal] Refactor updating account related Core Data operations, which ususally happens during log in and out of the app. [#20394]
* [***] [internal] Refactor uploading photos (from the device photo, the Free Photo library, and other sources) to the WordPress Media Library. Affected areas are where you can choose a photo and upload, including the "Media" screen, adding images to a post, updating site icon, etc. [#20322]
* [**] [WordPress-only] Warns user about sites with only individual plugins not supporting core app features and offers the option to switch to the Jetpack app. [#20408]
* [**] Add a "Personalize Home Tab" button to the bottom of the Home tab that allows changing cards visibility. [#20369]
* [**] [internal] Refactored Google SignIn implementation to not use the Google SDK [#20128]

22.0
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import Foundation
/// Make sure to keep them in sync to avoid build errors when builing the Jetpack target.
@objc class AppDependency: NSObject {
static func authenticationManager(windowManager: WindowManager) -> WordPressAuthenticationManager {
return WordPressAuthenticationManager(windowManager: windowManager)
return WordPressAuthenticationManager(
windowManager: windowManager,
remoteFeaturesStore: RemoteFeatureFlagStore()
)
}

static func windowManager(window: UIWindow) -> WindowManager {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ enum RemoteFeatureFlag: Int, CaseIterable {
case directDomainsPurchaseDashboardCard
case pagesDashboardCard
case activityLogDashboardCard
case sdkLessGoogleSignIn

var defaultValue: Bool {
switch self {
Expand Down Expand Up @@ -47,6 +48,8 @@ enum RemoteFeatureFlag: Int, CaseIterable {
return false
case .activityLogDashboardCard:
return false
case .sdkLessGoogleSignIn:
return false
}
}

Expand Down Expand Up @@ -81,6 +84,8 @@ enum RemoteFeatureFlag: Int, CaseIterable {
return "dashboard_card_pages"
case .activityLogDashboardCard:
return "dashboard_card_activity_log"
case .sdkLessGoogleSignIn:
return "google_signin_without_sdk"
}
}

Expand Down Expand Up @@ -114,6 +119,8 @@ enum RemoteFeatureFlag: Int, CaseIterable {
return "Pages Dashboard Card"
case .activityLogDashboardCard:
return "Activity Log Dashboard Card"
case .sdkLessGoogleSignIn:
return "Sign-In with Google without the Google SDK"
}
}

Expand Down
10 changes: 2 additions & 8 deletions WordPress/Classes/ViewRelated/NUX/LoginEpilogueUserInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,7 @@ extension LoginEpilogueUserInfo {
/// Updates the Epilogue properties, given a SocialService instance.
///
mutating func update(with service: SocialService) {
switch service {
case .google(let user):
fullName = user.profile?.name ?? String()
email = user.profile?.email ?? String()
case .apple(let user):
fullName = user.fullName
email = user.email
}
fullName = service.user.fullName
email = service.user.email
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ class WordPressAuthenticationManager: NSObject {

private let recentSiteService: RecentSitesService

private let remoteFeaturesStore: RemoteFeatureFlagStore

init(windowManager: WindowManager,
authenticationHandler: AuthenticationHandler? = nil,
quickStartSettings: QuickStartSettings = QuickStartSettings(),
recentSiteService: RecentSitesService = RecentSitesService()) {
recentSiteService: RecentSitesService = RecentSitesService(),
remoteFeaturesStore: RemoteFeatureFlagStore) {
self.windowManager = windowManager
self.authenticationHandler = authenticationHandler
self.quickStartSettings = quickStartSettings
self.recentSiteService = recentSiteService
self.remoteFeaturesStore = remoteFeaturesStore
}

/// Support is only available to the WordPress iOS App. Our Authentication Framework doesn't have direct access.
Expand Down Expand Up @@ -59,6 +63,16 @@ extension WordPressAuthenticationManager {
// Ref https://github.com/wordpress-mobile/WordPress-iOS/pull/12332#issuecomment-521994963
let enableSignInWithApple = !(BuildConfiguration.current ~= [.a8cBranchTest, .a8cPrereleaseTesting])

let googleLogingWithoutSDK: Bool = {
switch BuildConfiguration.current {
case .appStore:
// Rely on the remote flag in production
return RemoteFeatureFlag.sdkLessGoogleSignIn.enabled(using: remoteFeaturesStore)
default:
return true
}
}()

return WordPressAuthenticatorConfiguration(wpcomClientId: ApiCredentials.client,
wpcomSecret: ApiCredentials.secret,
wpcomScheme: WPComScheme,
Expand All @@ -75,7 +89,8 @@ extension WordPressAuthenticationManager {
enableSignupWithGoogle: AppConfiguration.allowSignUp,
enableUnifiedAuth: true,
enableUnifiedCarousel: FeatureFlag.unifiedPrologueCarousel.enabled,
enableSocialLogin: true)
enableSocialLogin: true,
googleLoginWithoutSDK: googleLogingWithoutSDK)
}

private func authenticatorStyle() -> WordPressAuthenticatorStyle {
Expand Down
6 changes: 5 additions & 1 deletion WordPress/Jetpack/AppDependency.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import Foundation
/// Make sure to keep them in sync to avoid build errors when builing the WordPress target.
@objc class AppDependency: NSObject {
static func authenticationManager(windowManager: WindowManager) -> WordPressAuthenticationManager {
return WordPressAuthenticationManager(windowManager: windowManager, authenticationHandler: JetpackAuthenticationManager())
return WordPressAuthenticationManager(
windowManager: windowManager,
authenticationHandler: JetpackAuthenticationManager(),
remoteFeaturesStore: RemoteFeatureFlagStore()
)
}

static func windowManager(window: UIWindow) -> WindowManager {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ class PrepublishingNudgesViewControllerTests: XCTestCase {

/// We need that in order to initialize the Authenticator, otherwise this test crashes
/// This is because we're using the NUXButton. Ideally, that component should be extracted
WordPressAuthenticationManager(windowManager: windowManager).initializeWordPressAuthenticator()
WordPressAuthenticationManager(
windowManager: windowManager,
remoteFeaturesStore: RemoteFeatureFlagStore()
).initializeWordPressAuthenticator()
}

/// Call the completion block when the "Publish" button is pressed
Expand Down

0 comments on commit 4085c5b

Please sign in to comment.