File tree Expand file tree Collapse file tree 2 files changed +14
-11
lines changed Expand file tree Collapse file tree 2 files changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,10 @@ export class AuthGuardFirebase implements CanActivate {
4242 req [ 'user' ] = decodedJwt
4343 }
4444 } catch ( error ) {
45- console . log ( error )
45+ this . logger . log (
46+ `JWT decode error ${ error as string } ` ,
47+ AuthGuardFirebase . name
48+ )
4649 // do nothing if decoding fails here
4750 }
4851 return true
@@ -88,14 +91,14 @@ export class AuthGuardFirebase implements CanActivate {
8891 } else {
8992 this . logger . error ( 'JWT:' , token )
9093 }
91- console . log ( 'AuthGuardFirebase: error decoding jwt, returning false' )
94+ this . logger . log ( 'AuthGuardFirebase: error decoding jwt, returning false' )
9295 return false
9396 }
9497 }
9598
9699 async decodeJwt ( token ) {
97100 return await this . firebaseAuthService . verifyIdToken (
98- token . replace ( 'Bearer ' , '' ) ,
101+ token ? token . replace ( 'Bearer ' , '' ) : '' ,
99102 true
100103 )
101104 }
Original file line number Diff line number Diff line change @@ -191,18 +191,18 @@ export class UserService {
191191 }
192192
193193 async ensureMirrorUserExists ( token : string ) {
194- const decodedToken = await this . firebaseAuthService . verifyIdToken ( token )
195- const firebaseUID = decodedToken . uid
194+ try {
195+ const decodedToken = await this . firebaseAuthService . verifyIdToken ( token )
196+ const firebaseUID = decodedToken . uid
196197
197- const _id = new mongo . ObjectId ( )
198+ const _id = new mongo . ObjectId ( )
198199
199- if ( ! decodedToken ) {
200- throw new NotFoundException ( 'User not found' )
201- }
200+ if ( ! decodedToken ) {
201+ throw new NotFoundException ( 'User not found' )
202+ }
202203
203- const user = await this . userModel . findOne ( { firebaseUID } ) . exec ( )
204+ const user = await this . userModel . findOne ( { firebaseUID } ) . exec ( )
204205
205- try {
206206 if ( ! user ) {
207207 const displayName = this . _generateUniqueUsername ( )
208208 const userModel = new this . userModel ( {
You can’t perform that action at this time.
0 commit comments