Skip to content

Commit 75d2faf

Browse files
committed
Cleanup
1 parent 1227182 commit 75d2faf

File tree

1 file changed

+20
-30
lines changed

1 file changed

+20
-30
lines changed

packages/auth/src/core/auth/auth_impl.ts

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -94,28 +94,6 @@ export const enum DefaultConfig {
9494
API_SCHEME = 'https'
9595
}
9696

97-
98-
async function loadUserFromIdToken(
99-
auth: AuthInternal,
100-
idToken: string
101-
): Promise<UserInternal|null> {
102-
try {
103-
const response = await getAccountInfo(auth, { idToken });
104-
const user = await UserImpl._fromGetAccountInfoResponse(
105-
auth,
106-
response,
107-
idToken
108-
);
109-
return user;
110-
} catch (err) {
111-
console.warn(
112-
'FirebaseServerApp could not login user with provided authIdToken: ',
113-
err
114-
);
115-
return null;
116-
}
117-
}
118-
11997
export class AuthImpl implements AuthInternal, _FirebaseService {
12098
currentUser: User | null = null;
12199
emulatorConfig: EmulatorConfig | null = null;
@@ -242,6 +220,23 @@ export class AuthImpl implements AuthInternal, _FirebaseService {
242220
await this._updateCurrentUser(user, /* skipBeforeStateCallbacks */ true);
243221
}
244222

223+
private async loadUserFromIdToken(idToken: string): Promise<void> {
224+
try {
225+
const response = await getAccountInfo(this, { idToken });
226+
const user = await UserImpl._fromGetAccountInfoResponse(
227+
this,
228+
response,
229+
idToken
230+
);
231+
await this.directlySetCurrentUser(user);
232+
} catch (err) {
233+
console.warn(
234+
'FirebaseServerApp could not login user with provided authIdToken: ',
235+
err
236+
);
237+
}
238+
}
239+
245240
private async initializeCurrentUser(
246241
popupRedirectResolver?: PopupRedirectResolver
247242
): Promise<void> {
@@ -270,16 +265,11 @@ export class AuthImpl implements AuthInternal, _FirebaseService {
270265
}
271266

272267
if (_isFirebaseServerApp(this.app)) {
273-
if (this.app.settings.authIdToken !== undefined) {
274-
const idToken = this.app.settings.authIdToken;
268+
const idToken = this.app.settings.authIdToken;
269+
if (idToken) {
275270
// Start the auth operation in the next tick to allow a moment for the customer's app to
276271
// attach an emulator, if desired.
277-
setTimeout(() =>
278-
void loadUserFromIdToken(this, idToken).then(user =>
279-
void this.directlySetCurrentUser(user)
280-
),
281-
0
282-
);
272+
setTimeout(() => void this.loadUserFromIdToken(idToken), 0);
283273
return;
284274
}
285275
}

0 commit comments

Comments
 (0)