Skip to content

Commit

Permalink
Revert "Refactor: Add error case (#47)"
Browse files Browse the repository at this point in the history
This reverts commit 0c1460b.
  • Loading branch information
sally0226 committed Aug 14, 2024
1 parent 0c1460b commit d92945e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 36 deletions.
14 changes: 8 additions & 6 deletions src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Response } from 'express';

import { KakaoInfo } from 'src/common/decorators/kakao-info.decorator';
import { KakaoGuard } from 'src/common/guards/kakao.guard';
import { getCookieOption } from 'src/common/helper/cookie.helper';
import { UserProvider } from 'src/entities';

import { AuthService } from './auth.service';
Expand All @@ -33,11 +32,14 @@ export class AuthController {
kakaoRefreshToken: refreshToken,
});

res.cookie(
'Authorization',
'Bearer ' + user.accessToken,
getCookieOption(),
);
res.cookie('Authorization', 'Bearer ' + user.accessToken, {
httpOnly: true,
sameSite: 'none',
secure: true,
path: '/',
expires: new Date(new Date().getTime() + 1000 * 60 * 60 * 24 * 1 * 365),
domain: '.korrk.kr',
});

return res.redirect(302, this.configService.get('CLIENT_URL'));
}
Expand Down
11 changes: 2 additions & 9 deletions src/auth/strategies/jwt.strategy.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import {
Injectable,
NotFoundException,
UnauthorizedException,
} from '@nestjs/common';
import { Injectable, UnauthorizedException } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { PassportStrategy } from '@nestjs/passport';

import { ExtractJwt, Strategy, VerifiedCallback } from 'passport-jwt';

import { User } from 'src/entities/index';
import { UserService } from 'src/user/user.service';

@Injectable()
Expand All @@ -24,14 +19,12 @@ export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') {
}

async validate(payload: { id: number }, done: VerifiedCallback) {
const user: User = await this.userService.findOne({
const user = await this.userService.findOne({
id: payload.id,
});
if (!user) {
throw new UnauthorizedException('존재하지 않는 유저입니다.');
}
if (user.nickname == null)
throw new NotFoundException('닉네임 설정을 완료해주세요.');
done(null, user);
}
}
21 changes: 0 additions & 21 deletions src/common/helper/cookie.helper.ts

This file was deleted.

0 comments on commit d92945e

Please sign in to comment.