|
1 | 1 | import { getAuth } from 'firebase-admin/auth'; |
2 | 2 | import { getStorage } from 'firebase-admin/storage'; |
| 3 | +import { LogLevel } from '@logtail/types'; |
3 | 4 | import { StandardRecord } from '../../definition/app.js'; |
4 | 5 | import { PocketNewParams, UserNewParams, UserProfile, UserSession, UserSettings } from '../../definition/user.js'; |
5 | 6 | import { getFileFromStorage, getFileMetadata, uploadFileToStorage } from './storage_utils.js'; |
6 | 7 | import { User } from '../../classes/User.js'; |
7 | 8 | import { encryptData } from '../encryption/encryption.js'; |
8 | 9 | import { schemaUserProfile } from '../../definition/schema.js'; |
| 10 | +import { logger } from '../logger/logger.js'; |
9 | 11 |
|
10 | 12 | export const getUserAuthDetails = async (auth_uid: string) => { |
11 | | - const userRecord = await getAuth().getUser(auth_uid); |
| 13 | + try { |
| 14 | + const userRecord = await getAuth().getUser(auth_uid); |
| 15 | + |
| 16 | + const auth_provider = userRecord.providerData[0]?.providerId || 'email'; |
12 | 17 |
|
13 | | - const auth_provider = userRecord.providerData[0]?.providerId || 'email'; |
| 18 | + return { email: userRecord.email, auth_provider, createdAt: userRecord.metadata.creationTime }; |
| 19 | + } catch (error) { |
| 20 | + logger(LogLevel.Warn, String(error?.message)); |
14 | 21 |
|
15 | | - return { email: userRecord.email, auth_provider, createdAt: userRecord.metadata.creationTime }; |
| 22 | + return; |
| 23 | + } |
16 | 24 | }; |
17 | 25 |
|
18 | 26 | export const getUsersID = async () => { |
@@ -290,7 +298,11 @@ export const decodeUserIdToken = async (token: string) => { |
290 | 298 | }; |
291 | 299 |
|
292 | 300 | export const deleteAuthUser = async (uid: string) => { |
293 | | - await getAuth().deleteUser(uid); |
| 301 | + try { |
| 302 | + await getAuth().deleteUser(uid); |
| 303 | + } catch (error) { |
| 304 | + console.error('Failed to delete auth user', err); |
| 305 | + } |
294 | 306 | }; |
295 | 307 |
|
296 | 308 | export const setUserFlags = async (id: string, flags: string[]) => { |
|
0 commit comments