@@ -96,19 +96,10 @@ class FirebaseUserImpl internal constructor(
96
96
jsonParser
97
97
.parseToJsonElement(String (Base64 .getUrlDecoder().decode(idToken.split(" ." )[1 ])))
98
98
.jsonObject
99
- .run { value as Map <String , Any ?>? }
99
+ .run { value as ? Map <String , Any ?>? }
100
100
.orEmpty()
101
101
}
102
102
103
- <<<<<<< HEAD
104
- val JsonElement .value get(): Any? = when (this ) {
105
- is JsonNull -> null
106
- is JsonArray -> map { it.value }
107
- is JsonObject -> jsonObject.mapValues { (_, it) -> it.value }
108
- is JsonPrimitive -> booleanOrNull ? : doubleOrNull ? : content
109
- else -> TODO ()
110
- }
111
- ====== =
112
103
internal val JsonElement .value get(): Any? =
113
104
when (this ) {
114
105
is JsonNull -> null
@@ -117,7 +108,6 @@ class FirebaseUserImpl internal constructor(
117
108
is JsonPrimitive -> booleanOrNull ? : doubleOrNull ? : content
118
109
else -> TODO ()
119
110
}
120
- >>>>>>> 25efe1c (ktlint formatting + update of user data after signInWithCustomToken + photoUrl and displayName implementation)
121
111
122
112
override fun delete (): Task <Void > {
123
113
val source = TaskCompletionSource <Void >()
@@ -261,19 +251,10 @@ class FirebaseAuth constructor(
261
251
setResult : (responseBody: String ) -> FirebaseUserImpl ? ,
262
252
): TaskCompletionSource <AuthResult > {
263
253
val source = TaskCompletionSource <AuthResult >()
264
- <<<<<<< HEAD
265
254
val request = Request .Builder ()
266
255
.url(urlFactory.buildUrl(url))
267
256
.post(body)
268
257
.build()
269
- ====== =
270
- val request =
271
- Request
272
- .Builder ()
273
- .url(urlFactory.buildUrl(url))
274
- .post(body)
275
- .build()
276
- >>>>>>> 25efe1c (ktlint formatting + update of user data after signInWithCustomToken + photoUrl and displayName implementation)
277
258
278
259
client.newCall(request).enqueue(
279
260
object : Callback {
@@ -284,26 +265,12 @@ class FirebaseAuth constructor(
284
265
source.setException(FirebaseException (e.toString(), e))
285
266
}
286
267
287
- <<<<<<< HEAD
288
- @Throws(IOException ::class )
289
- override fun onResponse (call : Call , response : Response ) {
290
- if (! response.isSuccessful) {
291
- source.setException(
292
- createAuthInvalidUserException(" accounts" , request, response)
293
- )
294
- } else {
295
- if (response.body()?.use { it.string() }?.also { responseBody ->
296
- user = setResult(responseBody)
297
- source.setResult(AuthResult { user })
298
- } == null ) {
299
- ====== =
300
268
@Throws(IOException ::class )
301
269
override fun onResponse (
302
270
call : Call ,
303
271
response : Response ,
304
272
) {
305
273
if (! response.isSuccessful) {
306
- >>>>>>> 25efe1c (ktlint formatting + update of user data after signInWithCustomToken + photoUrl and displayName implementation)
307
274
source.setException(
308
275
createAuthInvalidUserException(" accounts" , request, response),
309
276
)
@@ -325,9 +292,6 @@ class FirebaseAuth constructor(
325
292
}
326
293
327
294
companion object {
328
- @JvmStatic
329
- fun getInstance (): FirebaseAuth = getInstance(FirebaseApp .getInstance())
330
-
331
295
@JvmStatic
332
296
fun getInstance (app : FirebaseApp ): FirebaseAuth = app.get(FirebaseAuth ::class .java)
333
297
@@ -382,57 +346,33 @@ class FirebaseAuth constructor(
382
346
private var urlFactory = UrlFactory (app)
383
347
384
348
fun signInAnonymously (): Task <AuthResult > {
385
- <<<<<<< HEAD
386
349
val source = enqueueAuthPost(
387
350
url = " identitytoolkit.googleapis.com/v1/accounts:signUp" ,
388
351
body = RequestBody .create(json, JsonObject (mapOf (" returnSecureToken" to JsonPrimitive (true ))).toString()),
389
352
setResult = { responseBody ->
390
353
FirebaseUserImpl (app, jsonParser.parseToJsonElement(responseBody).jsonObject, isAnonymous = true )
391
- }
354
+ },
392
355
)
393
- ====== =
394
- val source =
395
- enqueueAuthPost(
396
- url = " identitytoolkit.googleapis.com/v1/accounts:signUp" ,
397
- body = RequestBody .create(json, JsonObject (mapOf (" returnSecureToken" to JsonPrimitive (true ))).toString()),
398
- setResult = { responseBody ->
399
- FirebaseUserImpl (app, jsonParser.parseToJsonElement(responseBody).jsonObject, isAnonymous = true )
400
- },
401
- )
402
- >>>>>>> 25efe1c (ktlint formatting + update of user data after signInWithCustomToken + photoUrl and displayName implementation)
403
356
return source.task
404
357
}
405
358
406
359
fun signInWithCustomToken (customToken : String ): Task <AuthResult > {
407
- <<<<<<< HEAD
408
360
val source = enqueueAuthPost(
409
361
url = " www.googleapis.com/identitytoolkit/v3/relyingparty/verifyCustomToken" ,
410
362
body = RequestBody .create(
411
363
json,
412
- JsonObject (mapOf (" token" to JsonPrimitive (customToken), " returnSecureToken" to JsonPrimitive (true ))).toString()
364
+ JsonObject (mapOf (" token" to JsonPrimitive (customToken), " returnSecureToken" to JsonPrimitive (true ))).toString(),
413
365
),
414
366
setResult = { responseBody ->
415
367
FirebaseUserImpl (app, jsonParser.parseToJsonElement(responseBody).jsonObject)
416
- ====== =
417
- val source =
418
- enqueueAuthPost(
419
- url = " www.googleapis.com/identitytoolkit/v3/relyingparty/verifyCustomToken" ,
420
- body =
421
- RequestBody .create(
422
- json,
423
- JsonObject (mapOf (" token" to JsonPrimitive (customToken), " returnSecureToken" to JsonPrimitive (true ))).toString(),
424
- ),
425
- setResult = { responseBody ->
426
- FirebaseUserImpl (app, jsonParser.parseToJsonElement(responseBody).jsonObject)
427
- },
428
- ).task.addOnSuccessListener {
429
- updateByGetAccountInfo()
430
- >>>>>>> 25efe1c (ktlint formatting + update of user data after signInWithCustomToken + photoUrl and displayName implementation)
431
- }
432
- return source
368
+ },
369
+ ).task.continueWith {
370
+ updateByGetAccountInfo()
371
+ }
372
+ return source.result
433
373
}
434
374
435
- internal fun updateByGetAccountInfo (): Task <AuthResult > {
375
+ private fun updateByGetAccountInfo (): Task <AuthResult > {
436
376
val source = TaskCompletionSource <AuthResult >()
437
377
438
378
val body =
@@ -496,18 +436,6 @@ class FirebaseAuth constructor(
496
436
return source.task
497
437
}
498
438
499
- <<<<<<< HEAD
500
- fun createUserWithEmailAndPassword (email : String , password : String ): Task <AuthResult > {
501
- val source = enqueueAuthPost(
502
- url = " www.googleapis.com/identitytoolkit/v3/relyingparty/signupNewUser" ,
503
- body = RequestBody .create(
504
- json,
505
- JsonObject (
506
- mapOf (
507
- " email" to JsonPrimitive (email),
508
- " password" to JsonPrimitive (password),
509
- " returnSecureToken" to JsonPrimitive (true )
510
- ====== =
511
439
fun createUserWithEmailAndPassword (
512
440
email : String ,
513
441
password : String ,
@@ -530,33 +458,12 @@ class FirebaseAuth constructor(
530
458
FirebaseUserImpl (
531
459
app = app,
532
460
data = jsonParser.parseToJsonElement(responseBody).jsonObject,
533
- >>>>>>> 25efe1c (ktlint formatting + update of user data after signInWithCustomToken + photoUrl and displayName implementation)
534
461
)
535
462
},
536
463
)
537
464
return source.task
538
465
}
539
466
540
- <<<<<<< HEAD
541
-
542
- fun signInWithEmailAndPassword (email : String , password : String ): Task <AuthResult > {
543
- val source = enqueueAuthPost(
544
- url = " www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword" ,
545
- body = RequestBody .create(
546
- json,
547
- JsonObject (
548
- mapOf (
549
- " email" to JsonPrimitive (email),
550
- " password" to JsonPrimitive (password),
551
- " returnSecureToken" to JsonPrimitive (true )
552
- )
553
- ).toString()
554
- ),
555
- setResult = { responseBody ->
556
- FirebaseUserImpl (app, jsonParser.parseToJsonElement(responseBody).jsonObject)
557
- }
558
- )
559
- ====== =
560
467
fun signInWithEmailAndPassword (
561
468
email : String ,
562
469
password : String ,
@@ -579,7 +486,6 @@ class FirebaseAuth constructor(
579
486
FirebaseUserImpl (app, jsonParser.parseToJsonElement(responseBody).jsonObject)
580
487
},
581
488
)
582
- >>>>>>> 25efe1c (ktlint formatting + update of user data after signInWithCustomToken + photoUrl and displayName implementation)
583
489
return source.task
584
490
}
585
491
@@ -600,11 +506,7 @@ class FirebaseAuth constructor(
600
506
? : " UNKNOWN_ERROR" ,
601
507
" $action API returned an error, " +
602
508
" with url [${request.method()} ] ${request.url()} ${request.body()} -- " +
603
- <<<<<<< HEAD
604
- " response [${response.code()} ] ${response.message()} $body "
605
- ====== =
606
509
" response [${response.code()} ] ${response.message()} $body " ,
607
- >>>>>>> 25efe1c (ktlint formatting + update of user data after signInWithCustomToken + photoUrl and displayName implementation)
608
510
)
609
511
}
610
512
@@ -913,20 +815,12 @@ class FirebaseAuth constructor(
913
815
idTokenListeners.remove(listener)
914
816
}
915
817
916
- <<<<<<< HEAD
917
818
fun useEmulator (host : String , port : Int ) {
918
819
urlFactory = UrlFactory (app, " http://$host :$port /" )
919
820
}
920
821
921
822
fun sendPasswordResetEmail (email : String , settings : ActionCodeSettings ? ): Task <Unit > = TODO ()
922
823
fun signInWithCredential (authCredential : AuthCredential ): Task <AuthResult > = TODO ()
923
- ====== =
924
- fun sendPasswordResetEmail (
925
- email : String ,
926
- settings : ActionCodeSettings ? ,
927
- ): Task <Unit > = TODO ()
928
-
929
- >>>>>>> 25efe1c (ktlint formatting + update of user data after signInWithCustomToken + photoUrl and displayName implementation)
930
824
fun checkActionCode (code : String ): Task <ActionCodeResult > = TODO ()
931
825
932
826
fun confirmPasswordReset (
@@ -957,14 +851,4 @@ class FirebaseAuth constructor(
957
851
): Task <AuthResult > = TODO ()
958
852
959
853
fun setLanguageCode (value : String ): Nothing = TODO ()
960
- <<<<<<< HEAD
961
- ====== =
962
-
963
- fun useEmulator (
964
- host : String ,
965
- port : Int ,
966
- ) {
967
- urlFactory = UrlFactory (app, " http://$host :$port /" )
968
- }
969
- >>>>>>> 25efe1c (ktlint formatting + update of user data after signInWithCustomToken + photoUrl and displayName implementation)
970
854
}
0 commit comments