From 948802ee254a5b5cafbccac4401d421f95bb2704 Mon Sep 17 00:00:00 2001 From: Borut Tomazin Date: Fri, 15 Nov 2024 14:49:01 +0100 Subject: [PATCH 1/4] Re-indentation. --- Sources/Google/GoogleAuthenticator.swift | 34 ++++++++++++++++++------ 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/Sources/Google/GoogleAuthenticator.swift b/Sources/Google/GoogleAuthenticator.swift index 6e7f88d..e03cfd9 100644 --- a/Sources/Google/GoogleAuthenticator.swift +++ b/Sources/Google/GoogleAuthenticator.swift @@ -23,14 +23,20 @@ extension GoogleAuthenticator: Authenticator { /// SignIn user. /// /// Will asynchronously return the `Response` object on success or `Error` on error. - public func signIn(from presentingViewController: UIViewController, - hint: String? = .none, - additionalScopes: [String]? = .none) async throws -> Response { + public func signIn( + from presentingViewController: UIViewController, + hint: String? = .none, + additionalScopes: [String]? = .none + ) async throws -> Response { guard !provider.hasPreviousSignIn() else { return try await restorePreviousSignIn() } - return try await signInUser(from: presentingViewController, hint: hint, additionalScopes: additionalScopes) + return try await signInUser( + from: presentingViewController, + hint: hint, + additionalScopes: additionalScopes + ) } /// Clears the signIn footprint and logs out the user immediatelly. @@ -46,7 +52,11 @@ extension GoogleAuthenticator: Authenticator { /// Boolean if given `url` should be handled. /// /// Call this from UIApplicationDelegate’s `application:openURL:options:` method. - public func canOpenUrl(_ url: URL, application: UIApplication, options: [UIApplication.OpenURLOptionsKey : Any]) -> Bool { + public func canOpenUrl( + _ url: URL, + application: UIApplication, + options: [UIApplication.OpenURLOptionsKey : Any] + ) -> Bool { GIDSignIn.sharedInstance.handle(url) } } @@ -66,11 +76,19 @@ private extension GoogleAuthenticator { } } } - - func signInUser(from presentingViewController: UIViewController, hint: String?, additionalScopes: [String]?) async throws -> Response { + + func signInUser( + from presentingViewController: UIViewController, + hint: String?, + additionalScopes: [String]? + ) async throws -> Response { try await withCheckedThrowingContinuation { continuation in provider - .signIn(withPresenting: presentingViewController, hint: hint, additionalScopes: additionalScopes) { result, error in + .signIn( + withPresenting: presentingViewController, + hint: hint, + additionalScopes: additionalScopes + ) { result, error in switch (result, error) { case (let signInResult?, _): continuation.resume(returning: signInResult.user.authResponse) From 5c2c647d13331e73fa4842c8b6ca1ccb75cc8f08 Mon Sep 17 00:00:00 2001 From: Borut Tomazin Date: Fri, 15 Nov 2024 14:51:27 +0100 Subject: [PATCH 2/4] Provide optional clientId. --- Sources/Google/GoogleAuthenticator.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sources/Google/GoogleAuthenticator.swift b/Sources/Google/GoogleAuthenticator.swift index e03cfd9..b454a28 100644 --- a/Sources/Google/GoogleAuthenticator.swift +++ b/Sources/Google/GoogleAuthenticator.swift @@ -25,6 +25,7 @@ extension GoogleAuthenticator: Authenticator { /// Will asynchronously return the `Response` object on success or `Error` on error. public func signIn( from presentingViewController: UIViewController, + clientId: String? = nil, hint: String? = .none, additionalScopes: [String]? = .none ) async throws -> Response { @@ -32,6 +33,9 @@ extension GoogleAuthenticator: Authenticator { return try await restorePreviousSignIn() } + // set clientId if provided (clientId is needed when doint auth via firebase) + clientId.map { provider.configuration = .init(clientID: $0) } + return try await signInUser( from: presentingViewController, hint: hint, From c7fd0e568fbf1e24ffe1673104f544f65e7e974f Mon Sep 17 00:00:00 2001 From: Borut Tomazin Date: Mon, 9 Dec 2024 14:48:02 +0100 Subject: [PATCH 3/4] Typo Co-authored-by: Egzon Arifi --- Sources/Google/GoogleAuthenticator.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Google/GoogleAuthenticator.swift b/Sources/Google/GoogleAuthenticator.swift index b454a28..533a110 100644 --- a/Sources/Google/GoogleAuthenticator.swift +++ b/Sources/Google/GoogleAuthenticator.swift @@ -33,7 +33,7 @@ extension GoogleAuthenticator: Authenticator { return try await restorePreviousSignIn() } - // set clientId if provided (clientId is needed when doint auth via firebase) + // set clientId if provided (clientId is needed when doing auth via firebase) clientId.map { provider.configuration = .init(clientID: $0) } return try await signInUser( From 31c7fe44aca3de8667b7e35a2ec6d030f1b75dd7 Mon Sep 17 00:00:00 2001 From: Borut Tomazin Date: Mon, 9 Dec 2024 14:52:32 +0100 Subject: [PATCH 4/4] Update runner. --- .github/workflows/Tests.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/Tests.yml b/.github/workflows/Tests.yml index 9627414..0723f50 100644 --- a/.github/workflows/Tests.yml +++ b/.github/workflows/Tests.yml @@ -1,13 +1,16 @@ name: Tests -on: - push: +on: pull_request: - types: [opened] + types: [opened, synchronize, reopened] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true jobs: Tests: - runs-on: macos-14-xlarge + runs-on: macos-15-xlarge steps: - name: Cancel previous jobs uses: styfle/cancel-workflow-action@0.11.0