issue #39
Some checks failed
Test CI / build (push) Failing after 28s

- 로그인 이후 access/refresh token 생성 및 반환 로직 구현
This commit is contained in:
2025-11-30 18:19:39 +09:00
parent 810b4c1fb0
commit 5c79aa18f4
20 changed files with 435 additions and 34 deletions

View File

@@ -0,0 +1,27 @@
import { Injectable, UnauthorizedException } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { JwtService } from '@nestjs/jwt';
import { PassportStrategy } from '@nestjs/passport';
import { ExtractJwt, Strategy } from 'passport-jwt';
import { AccountRepo } from 'src/modules/account/account.repo';
@Injectable()
export class JwtStrategy extends PassportStrategy(Strategy) {
constructor(
private readonly accountRepo: AccountRepo
, private readonly configService: ConfigService
, private readonly jwtService: JwtService
) {
super({
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
ignoreExpiration: false,
secretOrKey: configService.get<string>('JWT_SECRET')!
});
}
async validate(payload: any) {
const account = await this.accountRepo.findById(payload.id);
if (!account || account.length < 1) throw new UnauthorizedException();
return account[0];
}
}