- 어드민 웹(fanit_admin) 지원: GET products/list(비노출 포함 전체 상품, AdminProductDto)·GET orders/list(전 유저 주문, createdAt desc 커서 페이지네이션) 추가 — Hosting rewrite·직접 호출 양쪽에서 일관되는 2세그먼트 라우트
- 지갑·원장 어드민 응답도 DTO로 감싸 Timestamp({_seconds}) 유출 제거
- admin 함수에 단일 origin CORS 헤지 추가(OPTIONS preflight를 requireAdmin보다 먼저 처리, 에러 응답에도 헤더 적용)
- scripts/set-admin-claim.ts로 운영자 admin 클레임 부여(부여 후 재로그인 필요)
- Storage 규칙: write만 admin 클레임으로 제한, read는 불변(앱 이미지 표시 계약 유지)
- 신규 조회·DTO vitest 테스트 추가
28 lines
762 B
TypeScript
28 lines
762 B
TypeScript
/**
|
|
* 이메일로 유저를 찾아 admin custom claim(`admin: true`)을 부여한다.
|
|
*
|
|
* 사용법: npx tsx scripts/set-admin-claim.ts <email>
|
|
*/
|
|
import "./_bootstrap";
|
|
import { auth } from "../src/firebase";
|
|
|
|
async function main() {
|
|
const email = process.argv[2];
|
|
if (!email) {
|
|
console.error("사용법: npx tsx scripts/set-admin-claim.ts <email>");
|
|
process.exitCode = 1;
|
|
return;
|
|
}
|
|
|
|
const user = await auth.getUserByEmail(email);
|
|
await auth.setCustomUserClaims(user.uid, { admin: true });
|
|
|
|
console.log(`admin claim 부여 완료: ${email} (uid: ${user.uid})`);
|
|
console.log("반영을 위해 재로그인(또는 강제 토큰 갱신)이 필요합니다.");
|
|
}
|
|
|
|
main().catch((e) => {
|
|
console.error(e);
|
|
process.exitCode = 1;
|
|
});
|