diff --git a/dictation_server/src/features/auth/auth.controller.ts b/dictation_server/src/features/auth/auth.controller.ts index 32d7697..d756f8d 100644 --- a/dictation_server/src/features/auth/auth.controller.ts +++ b/dictation_server/src/features/auth/auth.controller.ts @@ -40,8 +40,6 @@ import { RedisService } from '../../gateways/redis/redis.service'; @Controller('auth') export class AuthController { constructor( - // TODO「タスク 1828: IDトークンを一度しか使えないようにする」で使用する予定 - // private readonly redisService: RedisService, private readonly authService: AuthService, private readonly redisService: RedisService, ) {} @@ -78,20 +76,18 @@ export class AuthController { ); } - const context = makeContext(uuidv4()); + const context = makeContext(idToken.sub); const key = makeIDTokenKey(body.idToken); const isTokenExists = await this.redisService.get(key); - if (!isTokenExists) { - // IDトークンがキャッシュに存在しない場合(idTokenの有効期限をADB2Cの有効期限と合わせる(300秒)) - await this.redisService.set(key, true, 300); - } else { + if (isTokenExists) { // IDトークンがキャッシュに存在する場合エラー throw new HttpException( makeErrorResponse('E000106'), HttpStatus.UNAUTHORIZED, ); } + // 同意済み利用規約バージョンが最新かチェック const isAcceptedLatestVersion = await this.authService.isAcceptedLatestVersion(context, idToken); @@ -104,6 +100,9 @@ export class AuthController { ); } + // IDトークンをキャッシュに保存(idTokenの有効期限をADB2Cの有効期限と合わせる(300秒)) + await this.redisService.set(key, true, 300); + const refreshToken = await this.authService.generateRefreshToken( context, idToken,