Skip to content

Commit 482a0fc

Browse files
Merge branch 'development' into clean-up-bugs
2 parents 356da89 + a1e2944 commit 482a0fc

File tree

21 files changed

+5409
-1268
lines changed

21 files changed

+5409
-1268
lines changed

FirebaseSwiftUI/FirebaseAppleSwiftUI/Sources/Views/SignInWithAppleButton.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public struct SignInWithAppleButton {
2929
extension SignInWithAppleButton: View {
3030
public var body: some View {
3131
AuthProviderButton(
32-
label: "Sign in with Apple",
32+
label: authService.string.appleLoginButtonLabel,
3333
style: .apple,
3434
accessibilityId: "sign-in-with-apple-button"
3535
) {

FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Services/AuthConfiguration.swift

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414

1515
import FirebaseAuth
1616
import Foundation
17+
import SwiftUI
1718

1819
public struct AuthConfiguration {
20+
public let logo: ImageResource?
21+
public let languageCode: String?
1922
public let shouldHideCancelButton: Bool
2023
public let interactiveDismissEnabled: Bool
2124
public let shouldAutoUpgradeAnonymousUsers: Bool
@@ -31,21 +34,27 @@ public struct AuthConfiguration {
3134
public let allowedSecondFactors: Set<SecondFactorType>
3235
public let mfaIssuer: String
3336

34-
public init(shouldHideCancelButton: Bool = false,
35-
interactiveDismissEnabled: Bool = true,
36-
shouldAutoUpgradeAnonymousUsers: Bool = false,
37-
customStringsBundle: Bundle? = nil,
38-
tosUrl: URL? = nil,
39-
privacyPolicyUrl: URL? = nil,
40-
emailLinkSignInActionCodeSettings: ActionCodeSettings? = nil,
41-
verifyEmailActionCodeSettings: ActionCodeSettings? = nil,
42-
mfaEnabled: Bool = false,
43-
allowedSecondFactors: Set<SecondFactorType> = [.sms, .totp],
44-
mfaIssuer: String = "Firebase Auth") {
37+
public init(
38+
logo: ImageResource? = nil,
39+
languageCode: String? = nil,
40+
shouldHideCancelButton: Bool = false,
41+
interactiveDismissEnabled: Bool = true,
42+
shouldAutoUpgradeAnonymousUsers: Bool = false,
43+
customStringsBundle: Bundle? = nil,
44+
tosUrl: URL? = nil,
45+
privacyPolicyUrl: URL? = nil,
46+
emailLinkSignInActionCodeSettings: ActionCodeSettings? = nil,
47+
verifyEmailActionCodeSettings: ActionCodeSettings? = nil,
48+
mfaEnabled: Bool = false,
49+
allowedSecondFactors: Set<SecondFactorType> = [.sms, .totp],
50+
mfaIssuer: String = "Firebase Auth"
51+
) {
52+
self.logo = logo
4553
self.shouldHideCancelButton = shouldHideCancelButton
4654
self.interactiveDismissEnabled = interactiveDismissEnabled
4755
self.shouldAutoUpgradeAnonymousUsers = shouldAutoUpgradeAnonymousUsers
4856
self.customStringsBundle = customStringsBundle
57+
self.languageCode = languageCode
4958
self.tosUrl = tosUrl
5059
self.privacyPolicyUrl = privacyPolicyUrl
5160
self.emailLinkSignInActionCodeSettings = emailLinkSignInActionCodeSettings

FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Services/AuthService.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ public protocol AuthProviderUI {
2727
var provider: AuthProviderSwift { get }
2828
}
2929

30-
public protocol PhoneAuthProviderSwift: AuthProviderSwift, AnyObject {
31-
// Phone auth provider that presents its own UI flow in createAuthCredential()
32-
// Internal use only: AuthService will be injected automatically by AuthService.signIn()
33-
var authService: AuthService? { get set }
30+
public protocol PhoneAuthProviderSwift: AuthProviderSwift {
31+
@MainActor func verifyPhoneNumber(phoneNumber: String) async throws -> String
32+
@MainActor func createAuthCredential(verificationId: String, verificationCode: String) async throws -> AuthCredential
3433
}
3534

3635
public enum AuthenticationState {
@@ -51,6 +50,8 @@ public enum AuthView: Hashable {
5150
case mfaEnrollment
5251
case mfaManagement
5352
case mfaResolution
53+
case enterPhoneNumber
54+
case enterVerificationCode(verificationID: String, fullPhoneNumber: String)
5455
}
5556

5657
public enum SignInOutcome: @unchecked Sendable {
@@ -108,7 +109,7 @@ public final class AuthService {
108109
public init(configuration: AuthConfiguration = AuthConfiguration(), auth: Auth = Auth.auth()) {
109110
self.auth = auth
110111
self.configuration = configuration
111-
string = StringUtils(bundle: configuration.customStringsBundle ?? Bundle.module)
112+
string = StringUtils(bundle: configuration.customStringsBundle ?? Bundle.module, languageCode: configuration.languageCode)
112113
listenerManager = AuthListenerManager(auth: auth, authEnvironment: self)
113114
FirebaseApp.registerLibrary("firebase-ui-ios", withVersion: FirebaseAuthSwiftUIVersion.version)
114115
}
@@ -159,6 +160,10 @@ public final class AuthService {
159160

160161
private var providers: [AuthProviderUI] = []
161162

163+
public var currentPhoneProvider: PhoneAuthProviderSwift? {
164+
providers.compactMap { $0.provider as? PhoneAuthProviderSwift }.first
165+
}
166+
162167
public func registerProvider(providerWithButton: AuthProviderUI) {
163168
providers.append(providerWithButton)
164169
}
@@ -182,11 +187,6 @@ public final class AuthService {
182187

183188
public func signIn(_ provider: AuthProviderSwift) async throws -> SignInOutcome {
184189
do {
185-
// Automatically inject AuthService for phone provider
186-
if let phoneProvider = provider as? PhoneAuthProviderSwift {
187-
phoneProvider.authService = self
188-
}
189-
190190
let credential = try await provider.createAuthCredential()
191191
let result = try await signIn(credentials: credential)
192192
return result

0 commit comments

Comments
 (0)