Skip to content

Commit 227d8e1

Browse files
chore: allow password prompt for changing password
1 parent 44594a1 commit 227d8e1

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Services/AccountService+Email.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class EmailPasswordDeleteUserOperation: AuthenticatedOperation,
3737
}
3838

3939
func callAsFunction(on user: User) async throws {
40-
try await callAsFunction(on: user) { _ in
40+
try await callAsFunction(on: user) {
4141
try await user.delete()
4242
}
4343
}
@@ -54,7 +54,7 @@ class EmailPasswordUpdatePasswordOperation: AuthenticatedOperation,
5454
}
5555

5656
func callAsFunction(on user: User) async throws {
57-
try await callAsFunction(on: user) { _ in
57+
try await callAsFunction(on: user) {
5858
try await user.updatePassword(to: newPassword)
5959
}
6060
}

FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Services/AccountService.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ protocol AuthenticatedOperation {
2323

2424
extension AuthenticatedOperation {
2525
func callAsFunction(on _: User,
26-
_ perform: (AuthenticationToken?) async throws -> Void) async throws {
26+
_ performOperation: () async throws -> Void) async throws {
2727
do {
28-
try await perform(nil)
28+
try await performOperation()
2929
} catch let error as NSError where error.requiresReauthentication {
3030
let token = try await reauthenticate()
31-
try await perform(token)
31+
try await performOperation()
3232
} catch AuthServiceError.reauthenticationRequired {
3333
let token = try await reauthenticate()
34-
try await perform(token)
34+
try await performOperation()
3535
}
3636
}
3737
}

FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Views/UpdatePassword.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ private enum FocusableField: Hashable {
1212
case confirmPassword
1313
}
1414

15+
@MainActor
1516
public struct UpdatePasswordView {
1617
@Environment(AuthService.self) private var authService
1718
@State private var password = ""
@@ -24,6 +25,13 @@ public struct UpdatePasswordView {
2425
}
2526

2627
extension UpdatePasswordView: View {
28+
private var isShowingPasswordPrompt: Binding<Bool> {
29+
Binding(
30+
get: { authService.passwordPrompt.isPromptingPassword },
31+
set: { authService.passwordPrompt.isPromptingPassword = $0 }
32+
)
33+
}
34+
2735
public var body: some View {
2836
VStack {
2937
LabeledContent {
@@ -70,6 +78,8 @@ extension UpdatePasswordView: View {
7078
.padding([.top, .bottom], 8)
7179
.frame(maxWidth: .infinity)
7280
.buttonStyle(.borderedProminent)
81+
}.sheet(isPresented: isShowingPasswordPrompt) {
82+
PasswordPromptSheet(coordinator: authService.passwordPrompt)
7383
}
7484
}
7585
}

0 commit comments

Comments
 (0)