From 1d54effa81171224c43279c01ae97fe1f9ae9a6c Mon Sep 17 00:00:00 2001 From: sheepdog13 Date: Sun, 4 Feb 2024 14:54:37 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20access=20token=20=EC=9C=A0=ED=9A=A8?= =?UTF-8?q?=ED=95=A0=EB=95=8C=20#26=20-=20access=20token=20=EC=9C=A0?= =?UTF-8?q?=ED=9A=A8=ED=95=A0=EB=95=8C=20access=20token=20=EB=B3=B5?= =?UTF-8?q?=ED=98=B8=ED=99=94=ED=9B=84=20-=20user=EC=A0=95=EB=B3=B4=20?= =?UTF-8?q?=EC=A0=84=EB=8B=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/middleware/auth.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server/middleware/auth.js b/server/middleware/auth.js index 5c59270..c6f76de 100644 --- a/server/middleware/auth.js +++ b/server/middleware/auth.js @@ -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);