Skip to content

Commit

Permalink
Fixes after self review
Browse files Browse the repository at this point in the history
  • Loading branch information
snaerseljan committed Nov 14, 2024
1 parent bc3c8c1 commit ce95573
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion apps/services/bff/src/app/modules/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
UnauthorizedException,
} from '@nestjs/common'
import { ConfigType } from '@nestjs/config'
import { Request, Response } from 'express'
import type { Request, Response } from 'express'
import jwksClient from 'jwks-rsa'
import { jwtDecode } from 'jwt-decode'

Expand Down
13 changes: 4 additions & 9 deletions apps/services/bff/src/app/modules/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { Request, Response } from 'express'

import { BffUser } from '@island.is/shared/types'
import { SESSION_COOKIE_NAME } from '../../constants/cookies'
import { CryptoService } from '../../services/crypto.service'

import { ErrorService } from '../../services/error.service'
import { hasTimestampExpiredInMS } from '../../utils/has-timestamp-expired-in-ms'
Expand All @@ -29,13 +28,6 @@ export class UserService {
}
}

/**
* Creates a key for storing token response data in cache
*/
private createTokenResponseKey(sid: string): string {
return this.cacheService.createSessionKeyType('current', sid)
}

/**
* Gets the current user data, refreshing the token if needed
*/
Expand All @@ -54,7 +46,10 @@ export class UserService {
throw new UnauthorizedException()
}

const tokenResponseKey = this.createTokenResponseKey(sid)
const tokenResponseKey = this.cacheService.createSessionKeyType(
'current',
sid,
)
const cachedTokenResponse =
await this.cacheService.get<CachedTokenResponse>(
tokenResponseKey,
Expand Down

0 comments on commit ce95573

Please sign in to comment.