Skip to content

Commit dbfb864

Browse files
[FR] Auth: Add noFetchUserRecord option to createUser/updateUser (firebase#1885)
1 parent 8dda32d commit dbfb864

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/auth/base-auth.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -417,11 +417,12 @@ export abstract class BaseAuth {
417417
* @returns A promise fulfilled with the user
418418
* data corresponding to the newly created user.
419419
*/
420-
public createUser(properties: CreateRequest): Promise<UserRecord> {
420+
public createUser(properties: CreateRequest,noFetchUserRecord:boolean=false): Promise<UserRecord|null> {
421421
return this.authRequestHandler.createNewAccount(properties)
422422
.then((uid) => {
423423
// Return the corresponding user record.
424-
return this.getUser(uid);
424+
if(noFetchUserRecord) return this.getUser(uid);
425+
return null
425426
})
426427
.catch((error) => {
427428
if (error.code === 'auth/user-not-found') {
@@ -531,7 +532,7 @@ export abstract class BaseAuth {
531532
* @returns A promise fulfilled with the
532533
* updated user data.
533534
*/
534-
public updateUser(uid: string, properties: UpdateRequest): Promise<UserRecord> {
535+
public updateUser(uid: string, properties: UpdateRequest,noFetchUserRecord:boolean=false): Promise<UserRecord | null> {
535536
// Although we don't really advertise it, we want to also handle linking of
536537
// non-federated idps with this call. So if we detect one of them, we'll
537538
// adjust the properties parameter appropriately. This *does* imply that a
@@ -579,7 +580,9 @@ export abstract class BaseAuth {
579580
return this.authRequestHandler.updateExistingAccount(uid, properties)
580581
.then((existingUid) => {
581582
// Return the corresponding user record.
583+
if(noFetchUserRecord)
582584
return this.getUser(existingUid);
585+
return null
583586
});
584587
}
585588

0 commit comments

Comments
 (0)