Skip to content

Commit e5af67d

Browse files
committed
AuthResult map parsing fixed in JS
1 parent 277e7f5 commit e5af67d

File tree

2 files changed

+9
-3
lines changed
  • firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth

2 files changed

+9
-3
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public actual class AuthResult(
118118
public actual val credential: AuthCredential?
119119
get() = rethrow { js.credential?.let { AuthCredential(it) } }
120120
public actual val additionalUserInfo: AdditionalUserInfo?
121-
get() = js.additionalUserInfo?.let { AdditionalUserInfo(it) }
121+
get() = rethrow { js.additionalUserInfo?.let { AdditionalUserInfo(it) } }
122122
}
123123

124124
public actual class AdditionalUserInfo(
@@ -129,7 +129,13 @@ public actual class AdditionalUserInfo(
129129
public actual val username: String?
130130
get() = js.username
131131
public actual val profile: Map<String, Any?>?
132-
get() = js.profile
132+
get() = rethrow {
133+
val profile = js.profile ?: return@rethrow null
134+
val entries = js("Object.entries") as (dynamic) -> Array<Array<Any?>>
135+
return@rethrow entries
136+
.invoke(profile)
137+
.associate { entry -> entry[0] as String to entry[1] }
138+
}
133139
public actual val isNewUser: Boolean
134140
get() = js.newUser
135141
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public external interface AuthResult {
176176
public external interface AdditionalUserInfo {
177177
public val providerId: String?
178178
public val username: String?
179-
public val profile: Map<String, Any?>?
179+
public val profile: dynamic
180180
public val newUser: Boolean
181181
}
182182

0 commit comments

Comments
 (0)