인증 구현하기(2)

리린·2021년 8월 5일
0

node.js

목록 보기
11/16

post 수정하기

로그인했을 때만 API 사용할 수 있도록 하기

  • lib/checkeLoggedIn.js
const checkLoggedIn = (ctx, next) => {
  if (!ctx.state.user) {
    ctx.status = 401;
    return;
  }
  return next();
};

export default checkLoggedIn;
  • 이 코드를 src/api/posts/index.js 에 적용시키기.
profile
개발자지망생

0개의 댓글