Skip to content

Commit

Permalink
fix : token table 엔티티 변경 #35
Browse files Browse the repository at this point in the history
- accessToken 컬럼 추가
  • Loading branch information
GeunH committed Dec 1, 2023
1 parent 55ea99e commit cd0c7b3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion be/src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class AuthService {
secret: "nibobnebob",
expiresIn: "7d",
});
await this.authRepository.upsert({ id: user.id, refreshToken: refreshToken }, ["id"]);
await this.authRepository.upsert({ id: user.id, accessToken: accessToken, refreshToken: refreshToken }, ["id"]);
return { accessToken, refreshToken };
} else {
throw new NotFoundException(
Expand All @@ -83,6 +83,7 @@ export class AuthService {
if (result) {
const payload = { id: decoded.id };
const accessToken = this.jwtService.sign(payload);
await this.authRepository.update(decoded.id, { accessToken: accessToken });
return { accessToken };
}
throw new HttpException("Invalid refresh token", HttpStatus.UNAUTHORIZED);
Expand Down
5 changes: 4 additions & 1 deletion be/src/auth/entity/auth.refreshtoken.entity.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { Entity, Column, PrimaryColumn } from 'typeorm';

@Entity("AuthRefreshToken")
@Entity("AuthToken")
export class AuthRefreshTokenEntity {
@PrimaryColumn()
id: number;

@Column({ type: 'varchar', length: 300 })
accessToken: string

@Column({ type: 'varchar', length: 300 })
refreshToken: string
}

0 comments on commit cd0c7b3

Please sign in to comment.