Skip to content

Commit 90cca1c

Browse files
committed
add signInWithEmailAndPassword to auth
1 parent c25e918 commit 90cca1c

File tree

6 files changed

+12
-1
lines changed
  • firebase-auth
  • firebase-common/src/jsMain/kotlin/dev/gitlive/firebase

6 files changed

+12
-1
lines changed

firebase-auth/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = "0.1.0"
1+
version = "0.2.0"
22

33
plugins {
44
id("com.android.library")

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ 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 signInWithEmailAndPassword(email: String, password: String) =
25+
AuthResult(android.signInWithEmailAndPassword(email, password).await())
26+
2427
actual suspend fun signInWithCustomToken(token: String) =
2528
AuthResult(android.signInWithCustomToken(token).await())
2629

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 signInWithEmailAndPassword(email: String, password: String): AuthResult
2021
suspend fun signInWithCustomToken(token: String): AuthResult
2122
suspend fun signInAnonymously(): AuthResult
2223
suspend fun signOut()

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ 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 signInWithEmailAndPassword(email: String, password: String) =
30+
AuthResult(ios.awaitResult { signInWithEmailAndPassword(email, password, it) })
31+
2932
actual suspend fun signInWithCustomToken(token: String) =
3033
AuthResult(ios.awaitResult { signInWithCustomToken(token, it) })
3134

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 signInWithEmailAndPassword(email: String, password: String) =
24+
rethrow { AuthResult(js.signInWithEmailAndPassword(email, password).await()) }
25+
2326
actual suspend fun signInWithCustomToken(token: String)
2427
= rethrow { AuthResult(js.signInWithCustomToken(token).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 signInWithEmailAndPassword(email: String, password: String): Promise<AuthResult>
6061
fun signInWithCustomToken(token: String): Promise<AuthResult>
6162
fun signInAnonymously(): Promise<AuthResult>
6263
fun signOut(): Promise<Unit>

0 commit comments

Comments
 (0)