File tree Expand file tree Collapse file tree 6 files changed +24
-0
lines changed
androidMain/kotlin/dev/gitlive/firebase/auth
commonMain/kotlin/dev/gitlive/firebase/auth
commonTest/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 Expand file tree Collapse file tree 6 files changed +24
-0
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ expect fun Firebase.auth(app: FirebaseApp): FirebaseAuth
1717expect 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
Original file line number Diff line number Diff line change @@ -46,4 +46,15 @@ class FirebaseAuthTest {
4646
4747 signInResult.user!! .delete()
4848 }
49+
50+ @Test
51+ fun sendPasswordResetEmail () = runTest {
52+ val email = " test+${Random .nextInt(100000 )} @test.com"
53+ val createResult = Firebase .auth.createUserWithEmailAndPassword(email, " test123" )
54+ assertNotEquals(null , createResult.user?.uid)
55+
56+ Firebase .auth.sendPasswordResetEmail(email)
57+
58+ createResult.user!! .delete()
59+ }
4960}
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 >
You can’t perform that action at this time.
0 commit comments