Skip to content

Commit

Permalink
fix: fix errors related to auth
Browse files Browse the repository at this point in the history
  • Loading branch information
Rybasher committed May 16, 2024
1 parent 7166535 commit 689ead2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions mirror-web-server/src/auth/auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class AuthGuardFirebase implements CanActivate {
req['user'] = decodedJwt
}
} catch (error) {
console.log(error)
this.logger.log(`JWT decode error ${error}`, AuthGuardFirebase.name)

Check failure on line 45 in mirror-web-server/src/auth/auth.guard.ts

View workflow job for this annotation

GitHub Actions / Unit (18.x)

Invalid type "any" of template literal expression

Check failure on line 45 in mirror-web-server/src/auth/auth.guard.ts

View workflow job for this annotation

GitHub Actions / Integration (18.x)

Invalid type "any" of template literal expression
// do nothing if decoding fails here
}
return true
Expand Down Expand Up @@ -88,14 +88,14 @@ export class AuthGuardFirebase implements CanActivate {
} else {
this.logger.error('JWT:', token)
}
console.log('AuthGuardFirebase: error decoding jwt, returning false')
this.logger.log('AuthGuardFirebase: error decoding jwt, returning false')
return false
}
}

async decodeJwt(token) {
return await this.firebaseAuthService.verifyIdToken(
token.replace('Bearer ', ''),
token ? token.replace('Bearer ', '') : '',
true
)
}
Expand Down
16 changes: 8 additions & 8 deletions mirror-web-server/src/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,18 +191,18 @@ export class UserService {
}

async ensureMirrorUserExists(token: string) {
const decodedToken = await this.firebaseAuthService.verifyIdToken(token)
const firebaseUID = decodedToken.uid
try {
const decodedToken = await this.firebaseAuthService.verifyIdToken(token)
const firebaseUID = decodedToken.uid

const _id = new mongo.ObjectId()
const _id = new mongo.ObjectId()

if (!decodedToken) {
throw new NotFoundException('User not found')
}
if (!decodedToken) {
throw new NotFoundException('User not found')
}

const user = await this.userModel.findOne({ firebaseUID }).exec()
const user = await this.userModel.findOne({ firebaseUID }).exec()

try {
if (!user) {
const displayName = this._generateUniqueUsername()
const userModel = new this.userModel({
Expand Down

0 comments on commit 689ead2

Please sign in to comment.