-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #311 from boostcampwm-2024/dev
[Deploy] 6주차 2차 배포
- Loading branch information
Showing
69 changed files
with
820 additions
and
724 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,29 @@ | ||
import { Injectable } from "@nestjs/common"; | ||
import { PassportStrategy } from "@nestjs/passport"; | ||
import { Strategy } from "passport-jwt"; | ||
import { Strategy } from "passport-custom"; | ||
import { Request } from "express"; | ||
import * as jwt from "jsonwebtoken"; | ||
import "dotenv/config"; | ||
|
||
@Injectable() | ||
export class AccessTokenStrategy extends PassportStrategy(Strategy, "jwt") { | ||
constructor() { | ||
super({ | ||
jwtFromRequest: (req: Request) => { | ||
if (!req || !req.cookies) return null; | ||
return req.cookies["accessToken"]; | ||
}, | ||
secretOrKey: process.env.JWT_ACCESS_TOKEN_SECRET_KEY, | ||
passReqToCallback: true, | ||
}); | ||
} | ||
async validate(req: Request) { | ||
try { | ||
const token = req.cookies?.accessToken; | ||
|
||
if (!token) return { jwtToken: null }; | ||
|
||
async validate(req: Request, payload: any) { | ||
const { userId, username } = payload; | ||
const decoded = jwt.verify(token, process.env.JWT_ACCESS_TOKEN_SECRET_KEY); | ||
const { userId, username } = decoded as any; | ||
|
||
return { | ||
jwtToken: { | ||
userId, | ||
username, | ||
}, | ||
}; | ||
return { | ||
jwtToken: { | ||
userId, | ||
username, | ||
}, | ||
}; | ||
} catch { | ||
return { jwtToken: null }; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { QuestionList } from "@/question-list/entity/question-list.entity"; | ||
|
||
export class QuestionListDto extends QuestionList { | ||
categoryNames?: string[]; | ||
} |
Oops, something went wrong.