Skip to content

Commit 06bf40a

Browse files
authored
Merge pull request #495 from chaynHQ/ignore-id-expired-error
Ignore firebase id token expired error
2 parents 1bb7b75 + 21af540 commit 06bf40a

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

src/firebase/firebase-auth.guard.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
UnauthorizedException,
88
} from '@nestjs/common';
99
import { Request } from 'express';
10+
import { FIREBASE_ERRORS } from 'src/utils/errors';
1011
import { AuthService } from '../auth/auth.service';
1112
import { UserService } from '../user/user.service';
1213
import { IFirebaseUser } from './firebase-user.interface';
@@ -32,7 +33,7 @@ export class FirebaseAuthGuard implements CanActivate {
3233
user = await this.authService.parseAuth(authorization);
3334
} catch (error) {
3435
if (error.code === 'auth/id-token-expired') {
35-
throw new HttpException(`FirebaseAuthGuard - ${error}`, HttpStatus.UNAUTHORIZED);
36+
throw new HttpException(FIREBASE_ERRORS.ID_TOKEN_EXPIRED, HttpStatus.UNAUTHORIZED);
3637
}
3738

3839
throw new HttpException(

src/partner-admin/partner-admin-auth.guard.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
import { InjectRepository } from '@nestjs/typeorm';
99
import { Request } from 'express';
1010
import { UserEntity } from 'src/entities/user.entity';
11+
import { FIREBASE_ERRORS } from 'src/utils/errors';
1112
import { Repository } from 'typeorm';
1213
import { AuthService } from '../auth/auth.service';
1314

@@ -31,7 +32,7 @@ export class PartnerAdminAuthGuard implements CanActivate {
3132
userUid = uid;
3233
} catch (error) {
3334
if (error.code === 'auth/id-token-expired') {
34-
throw new HttpException(`PartnerAdminAuthGuard - ${error}`, HttpStatus.UNAUTHORIZED);
35+
throw new HttpException(FIREBASE_ERRORS.ID_TOKEN_EXPIRED, HttpStatus.UNAUTHORIZED);
3536
}
3637

3738
throw new HttpException(

src/partner-admin/super-admin-auth.guard.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
import { InjectRepository } from '@nestjs/typeorm';
99
import { Request } from 'express';
1010
import { UserEntity } from 'src/entities/user.entity';
11+
import { FIREBASE_ERRORS } from 'src/utils/errors';
1112
import { Repository } from 'typeorm';
1213
import { AuthService } from '../auth/auth.service';
1314

@@ -35,7 +36,7 @@ export class SuperAdminAuthGuard implements CanActivate {
3536
userUid = uid;
3637
} catch (error) {
3738
if (error.code === 'auth/id-token-expired') {
38-
throw new HttpException(`SuperAdminAuthGuard - ${error}`, HttpStatus.UNAUTHORIZED);
39+
throw new HttpException(FIREBASE_ERRORS.ID_TOKEN_EXPIRED, HttpStatus.UNAUTHORIZED);
3940
}
4041

4142
throw new HttpException(

src/utils/errors.ts

+1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ export enum FIREBASE_ERRORS {
66
CREATE_USER_INVALID_EMAIL = 'CREATE_USER_INVALID_EMAIL',
77
CREATE_USER_WEAK_PASSWORD = 'CREATE_USER_WEAK_PASSWORD',
88
CREATE_USER_ALREADY_EXISTS = 'CREATE_USER_ALREADY_EXISTS',
9+
ID_TOKEN_EXPIRED = 'ID_TOKEN_EXPIRED',
910
}

0 commit comments

Comments
 (0)