Skip to content

Commit 2c470a4

Browse files
fix: pass in action code settings if available
1 parent a0dee1a commit 2c470a4

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Services/AuthService.swift

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -296,16 +296,24 @@ public final class AuthService {
296296
}
297297

298298
func sendEmailVerification() async throws {
299-
if currentUser != nil {
300-
do {
301-
// TODO: - can use set user action code settings?
302-
try await currentUser!.sendEmailVerification()
303-
} catch {
304-
errorMessage = string.localizedErrorMessage(
305-
for: error
306-
)
307-
throw error
299+
do {
300+
if let user = currentUser {
301+
// Requires running on MainActor as passing to sendEmailVerification() which is non-isolated
302+
let settings: ActionCodeSettings? = await MainActor.run {
303+
configuration.verifyEmailActionCodeSettings
304+
}
305+
306+
if let settings = settings {
307+
try await user.sendEmailVerification(with: settings)
308+
} else {
309+
try await user.sendEmailVerification()
310+
}
308311
}
312+
} catch {
313+
errorMessage = string.localizedErrorMessage(
314+
for: error
315+
)
316+
throw error
309317
}
310318
}
311319
}

0 commit comments

Comments
 (0)