Skip to content

Commit 2a83b5d

Browse files
committed
Firebase Auth: Add sendPasswordResetEmail.
1 parent c04945e commit 2a83b5d

File tree

5 files changed

+13
-0
lines changed
  • firebase-auth/src
    • androidMain/kotlin/dev/gitlive/firebase/auth
    • commonMain/kotlin/dev/gitlive/firebase/auth
    • iosMain/kotlin/dev/gitlive/firebase/auth
    • jsMain/kotlin/dev/gitlive/firebase/auth
  • firebase-common/src/jsMain/kotlin/dev/gitlive/firebase

5 files changed

+13
-0
lines changed

firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/auth.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ actual class FirebaseAuth internal constructor(val android: com.google.firebase.
2121
actual val currentUser: FirebaseUser?
2222
get() = android.currentUser?.let { FirebaseUser(it) }
2323

24+
actual suspend fun sendPasswordResetEmail(email: String) {
25+
android.sendPasswordResetEmail(email).await()
26+
}
27+
2428
actual suspend fun signInWithEmailAndPassword(email: String, password: String) =
2529
AuthResult(android.signInWithEmailAndPassword(email, password).await())
2630

firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/auth.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ expect fun Firebase.auth(app: FirebaseApp): FirebaseAuth
1717
expect class FirebaseAuth {
1818
val currentUser: FirebaseUser?
1919
val authStateChanged: Flow<FirebaseUser?>
20+
suspend fun sendPasswordResetEmail(email: String)
2021
suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult
2122
suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult
2223
suspend fun signInWithCustomToken(token: String): AuthResult

firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/auth.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ actual class FirebaseAuth internal constructor(val ios: FIRAuth) {
2626
actual val currentUser: FirebaseUser?
2727
get() = ios.currentUser?.let { FirebaseUser(it) }
2828

29+
actual suspend fun sendPasswordResetEmail(email: String) {
30+
ios.await { sendPasswordResetWithEmail(email = email, completion = it) }
31+
}
32+
2933
actual suspend fun signInWithEmailAndPassword(email: String, password: String) =
3034
AuthResult(ios.awaitResult { signInWithEmail(email = email, password = password, completion = it) })
3135

firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/auth.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ actual class FirebaseAuth internal constructor(val js: firebase.auth.Auth) {
2020
actual val currentUser: FirebaseUser?
2121
get() = rethrow { js.currentUser?.let { FirebaseUser(it) } }
2222

23+
actual suspend fun sendPasswordResetEmail(email: String) =
24+
rethrow { js.sendPasswordResetEmail(email).await() }
25+
2326
actual suspend fun signInWithEmailAndPassword(email: String, password: String) =
2427
rethrow { AuthResult(js.signInWithEmailAndPassword(email, password).await()) }
2528

firebase-common/src/jsMain/kotlin/dev/gitlive/firebase/externals.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ external object firebase {
5757
open class Auth {
5858
val currentUser: user.User?
5959

60+
fun sendPasswordResetEmail(email: String): Promise<Unit>
6061
fun signInWithEmailAndPassword(email: String, password: String): Promise<AuthResult>
6162
fun createUserWithEmailAndPassword(email: String, password: String): Promise<AuthResult>
6263
fun signInWithCustomToken(token: String): Promise<AuthResult>

0 commit comments

Comments
 (0)