@@ -7,12 +7,7 @@ import {
7
7
} from '@nestjs/common' ;
8
8
import { DecodedIdToken } from 'firebase-admin/lib/auth/token-verifier' ;
9
9
import { Logger } from 'src/logger/logger' ;
10
- import {
11
- CREATE_USER_ALREADY_EXISTS ,
12
- CREATE_USER_FIREBASE_ERROR ,
13
- CREATE_USER_INVALID_EMAIL ,
14
- CREATE_USER_WEAK_PASSWORD ,
15
- } from 'src/utils/errors' ;
10
+ import { FIREBASE_ERRORS } from 'src/utils/errors' ;
16
11
import { FIREBASE } from '../firebase/firebase-factory' ;
17
12
import { FirebaseServices } from '../firebase/firebase.types' ;
18
13
import { UserAuthDto } from './dto/user-auth.dto' ;
@@ -61,19 +56,19 @@ export class AuthService {
61
56
this . logger . warn (
62
57
`Create user: user tried to create email with invalid email: ${ email } - ${ err } ` ,
63
58
) ;
64
- throw new HttpException ( CREATE_USER_INVALID_EMAIL , HttpStatus . BAD_REQUEST ) ;
59
+ throw new HttpException ( FIREBASE_ERRORS . CREATE_USER_INVALID_EMAIL , HttpStatus . BAD_REQUEST ) ;
65
60
} else if ( errorCode === 'auth/weak-password' || errorCode === 'auth/invalid-password' ) {
66
61
this . logger . warn ( `Create user: user tried to create email with weak password - ${ err } ` ) ;
67
- throw new HttpException ( CREATE_USER_WEAK_PASSWORD , HttpStatus . BAD_REQUEST ) ;
62
+ throw new HttpException ( FIREBASE_ERRORS . CREATE_USER_WEAK_PASSWORD , HttpStatus . BAD_REQUEST ) ;
68
63
} else if (
69
64
errorCode === 'auth/email-already-in-use' ||
70
65
errorCode === 'auth/email-already-exists'
71
66
) {
72
67
this . logger . warn ( `Create user: Firebase user already exists: ${ email } ` ) ;
73
- throw new HttpException ( CREATE_USER_ALREADY_EXISTS , HttpStatus . BAD_REQUEST ) ;
68
+ throw new HttpException ( FIREBASE_ERRORS . CREATE_USER_ALREADY_EXISTS , HttpStatus . BAD_REQUEST ) ;
74
69
} else {
75
70
this . logger . error ( `Create user: Error creating firebase user - ${ email } : ${ err } ` ) ;
76
- throw new HttpException ( CREATE_USER_FIREBASE_ERROR , HttpStatus . BAD_REQUEST ) ;
71
+ throw new HttpException ( FIREBASE_ERRORS . CREATE_USER_FIREBASE_ERROR , HttpStatus . BAD_REQUEST ) ;
77
72
}
78
73
}
79
74
}
0 commit comments