Skip to content

Commit

Permalink
feat : access token 유효할때 #26
Browse files Browse the repository at this point in the history
- access token 유효할때 access token 복호화후
- user정보 전달
  • Loading branch information
sheepdog13 committed Feb 4, 2024
1 parent 028e84a commit 1d54eff
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions server/middleware/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ const { User } = require("../models/User");
let auth = async (req, res, next) => {
// 클라이언트에서 토큰을 가져온다
let token = req.headers.authorization;
if (token) {
const userdata = await User.findByToken(token);
req.user = userdata;
return next();
} else {
// refresh 토큰으로 access 토큰 재발급
}
try {
// 토큰을 복호화 한후 유저를 찾는다.
const userdata = await User.findByToken(token);
Expand Down

0 comments on commit 1d54eff

Please sign in to comment.