fromis_9/backend/src/plugins/auth.js
caadiq d44537d870 멤버 관리 API 구현 및 프론트엔드 연동
Backend:
- 멤버 CRUD API 추가 (routes/admin/members.js)
- 이미지 업로드 서비스 추가 (services/image.js)
  - S3에 3가지 해상도로 저장 (original, medium_800, thumb_400)
- multipart 플러그인 등록

Frontend:
- useAdminAuth 커스텀 훅 추가 (토큰 검증 API 사용)
- AdminMembers, AdminMemberEdit useQuery로 변경
- 로그인 확인 로직 중복 제거
- 수정 완료 시 목록 페이지로 이동 및 토스트 표시

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-16 23:01:23 +09:00

26 lines
626 B
JavaScript

import fp from 'fastify-plugin';
import fastifyJwt from '@fastify/jwt';
import config from '../config/index.js';
async function authPlugin(fastify, opts) {
// JWT 플러그인 등록
await fastify.register(fastifyJwt, {
secret: config.jwt.secret,
sign: {
expiresIn: config.jwt.expiresIn,
},
});
// 인증 데코레이터
fastify.decorate('authenticate', async function (request, reply) {
try {
await request.jwtVerify();
} catch (err) {
return reply.status(401).send({ error: '인증이 필요합니다.' });
}
});
}
export default fp(authPlugin, {
name: 'auth',
});