@@ -112,16 +112,17 @@ public final class AuthService {
112112 private func safeActionCodeSettings( emailLinkSignIn: Bool = true ) throws -> ActionCodeSettings {
113113 guard let actionCodeSettings = emailLinkSignIn ? configuration
114114 . emailLinkSignInActionCodeSettings : configuration. verifyEmailActionCodeSettings else {
115- let errorMessage = emailLinkSignIn ?
116- " ActionCodeSettings has not been configured for `AuthConfiguration.emailLinkSignInActionCodeSettings` " :
117- " ActionCodeSettings has not been configured for `AuthConfiguration.verifyEmailActionCodeSettings` "
115+ let settingType = emailLinkSignIn ? " emailLinkSignInActionCodeSettings " :
116+ " verifyEmailActionCodeSettings "
117+ let errorMessage =
118+ " ActionCodeSettings has not been configured for `AuthConfiguration. \( settingType) ` "
118119 throw AuthServiceError
119120 . notConfiguredActionCodeSettings ( errorMessage)
120121 }
121122 return actionCodeSettings
122123 }
123124
124- func updateAuthenticationState( ) {
125+ public func updateAuthenticationState( ) {
125126 authenticationState =
126127 ( currentUser == nil || currentUser? . isAnonymous == true )
127128 ? . unauthenticated
@@ -133,25 +134,6 @@ public final class AuthService {
133134 updateAuthenticationState ( )
134135 }
135136
136- public func signInWithGoogle( ) async throws {
137- authenticationState = . authenticating
138- do {
139- guard let clientID = auth. app? . options. clientID else {
140- throw AuthServiceError
141- . clientIdNotFound (
142- " OAuth client ID not found. Please make sure Google Sign-In is enabled in the Firebase console. You may have to download a new GoogleService-Info.plist file after enabling Google Sign-In. "
143- )
144- }
145- let credential = try await safeGoogleProvider. signInWithGoogle ( clientID: clientID)
146-
147- try await signIn ( with: credential)
148- updateAuthenticationState ( )
149- } catch {
150- authenticationState = . unauthenticated
151- throw error
152- }
153- }
154-
155137 public func signIn( with credentials: AuthCredential ) async throws {
156138 authenticationState = . authenticating
157139 do {
@@ -228,3 +210,26 @@ public final class AuthService {
228210 }
229211 }
230212}
213+
214+ // MARK: - Google Sign In
215+
216+ public extension AuthService {
217+ func signInWithGoogle( ) async throws {
218+ authenticationState = . authenticating
219+ do {
220+ guard let clientID = auth. app? . options. clientID else {
221+ throw AuthServiceError
222+ . clientIdNotFound (
223+ " OAuth client ID not found. Please make sure Google Sign-In is enabled in the Firebase console. You may have to download a new GoogleService-Info.plist file after enabling Google Sign-In. "
224+ )
225+ }
226+ let credential = try await safeGoogleProvider. signInWithGoogle ( clientID: clientID)
227+
228+ try await signIn ( with: credential)
229+ updateAuthenticationState ( )
230+ } catch {
231+ authenticationState = . unauthenticated
232+ throw error
233+ }
234+ }
235+ }
0 commit comments