Skip to content

Commit

Permalink
Merge pull request #496 from chaynHQ/develop
Browse files Browse the repository at this point in the history
Merge Develop onto Main
  • Loading branch information
annarhughes authored Jun 25, 2024
2 parents d7d0a0f + 06bf40a commit 2546082
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/firebase/firebase-auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
UnauthorizedException,
} from '@nestjs/common';
import { Request } from 'express';
import { FIREBASE_ERRORS } from 'src/utils/errors';
import { AuthService } from '../auth/auth.service';
import { UserService } from '../user/user.service';
import { IFirebaseUser } from './firebase-user.interface';
Expand All @@ -32,7 +33,7 @@ export class FirebaseAuthGuard implements CanActivate {
user = await this.authService.parseAuth(authorization);
} catch (error) {
if (error.code === 'auth/id-token-expired') {
throw new HttpException(`FirebaseAuthGuard - ${error}`, HttpStatus.UNAUTHORIZED);
throw new HttpException(FIREBASE_ERRORS.ID_TOKEN_EXPIRED, HttpStatus.UNAUTHORIZED);
}

throw new HttpException(
Expand Down
3 changes: 2 additions & 1 deletion src/partner-admin/partner-admin-auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
import { InjectRepository } from '@nestjs/typeorm';
import { Request } from 'express';
import { UserEntity } from 'src/entities/user.entity';
import { FIREBASE_ERRORS } from 'src/utils/errors';
import { Repository } from 'typeorm';
import { AuthService } from '../auth/auth.service';

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

throw new HttpException(
Expand Down
3 changes: 2 additions & 1 deletion src/partner-admin/super-admin-auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
import { InjectRepository } from '@nestjs/typeorm';
import { Request } from 'express';
import { UserEntity } from 'src/entities/user.entity';
import { FIREBASE_ERRORS } from 'src/utils/errors';
import { Repository } from 'typeorm';
import { AuthService } from '../auth/auth.service';

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

throw new HttpException(
Expand Down
1 change: 1 addition & 0 deletions src/utils/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export enum FIREBASE_ERRORS {
CREATE_USER_INVALID_EMAIL = 'CREATE_USER_INVALID_EMAIL',
CREATE_USER_WEAK_PASSWORD = 'CREATE_USER_WEAK_PASSWORD',
CREATE_USER_ALREADY_EXISTS = 'CREATE_USER_ALREADY_EXISTS',
ID_TOKEN_EXPIRED = 'ID_TOKEN_EXPIRED',
}

0 comments on commit 2546082

Please sign in to comment.