Skip to content

Commit 893e5a9

Browse files
committed
Firebase Auth: Add createUserWithEmailAndPassword.
1 parent 322bfd4 commit 893e5a9

File tree

5 files changed

+11
-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

+11
-0
lines changed

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
@@ -24,6 +24,9 @@ actual class FirebaseAuth internal constructor(val android: com.google.firebase.
2424
actual suspend fun signInWithEmailAndPassword(email: String, password: String) =
2525
AuthResult(android.signInWithEmailAndPassword(email, password).await())
2626

27+
actual suspend fun createUserWithEmailAndPassword(email: String, password: String) =
28+
AuthResult(android.createUserWithEmailAndPassword(email, password).await())
29+
2730
actual suspend fun signInWithCustomToken(token: String) =
2831
AuthResult(android.signInWithCustomToken(token).await())
2932

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
@@ -18,6 +18,7 @@ expect class FirebaseAuth {
1818
val currentUser: FirebaseUser?
1919
val authStateChanged: Flow<FirebaseUser?>
2020
suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult
21+
suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult
2122
suspend fun signInWithCustomToken(token: String): AuthResult
2223
suspend fun signInAnonymously(): AuthResult
2324
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
@@ -29,6 +29,9 @@ actual class FirebaseAuth internal constructor(val ios: FIRAuth) {
2929
actual suspend fun signInWithEmailAndPassword(email: String, password: String) =
3030
AuthResult(ios.awaitResult { signInWithEmail(email = email, password = password, completion = it) })
3131

32+
actual suspend fun createUserWithEmailAndPassword(email: String, password: String) =
33+
AuthResult(ios.awaitResult { createUserWithEmail(email = email, password = password, completion = it) })
34+
3235
actual suspend fun signInWithCustomToken(token: String) =
3336
AuthResult(ios.awaitResult { signInWithCustomToken(token, it) })
3437

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
@@ -23,6 +23,9 @@ actual class FirebaseAuth internal constructor(val js: firebase.auth.Auth) {
2323
actual suspend fun signInWithEmailAndPassword(email: String, password: String) =
2424
rethrow { AuthResult(js.signInWithEmailAndPassword(email, password).await()) }
2525

26+
actual suspend fun createUserWithEmailAndPassword(email: String, password: String) =
27+
rethrow { AuthResult(js.createUserWithEmailAndPassword(email, password).await()) }
28+
2629
actual suspend fun signInWithCustomToken(token: String)
2730
= rethrow { AuthResult(js.signInWithCustomToken(token).await()) }
2831

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

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

6060
fun signInWithEmailAndPassword(email: String, password: String): Promise<AuthResult>
61+
fun createUserWithEmailAndPassword(email: String, password: String): Promise<AuthResult>
6162
fun signInWithCustomToken(token: String): Promise<AuthResult>
6263
fun signInAnonymously(): Promise<AuthResult>
6364
fun signOut(): Promise<Unit>

0 commit comments

Comments
 (0)