Compare commits

...

11 Commits

18 changed files with 992 additions and 182 deletions

View File

@@ -6,3 +6,8 @@ ADMIN_ACCOUNT_ID=replace-with-private-admin-id
ADMIN_ACCOUNT_PASSWORD=replace-with-private-admin-password
ADMIN_ACCOUNT_EMAIL=admin@example.com
ADMIN_ACCOUNT_NICKNAME=Planner Admin
APP_BASE_URL=https://planner.sori.studio
RESEND_API_KEY=replace-with-private-resend-api-key
MAIL_FROM_EMAIL=planner@sori.studio
MAIL_FROM_NAME=10 Minute Planner
AUTH_PREVIEW_LINKS=false

View File

@@ -4,7 +4,7 @@
- 프로젝트명: 10 Minute Planner 웹 UI
- 기술 스택: Vue 3 + Vite + TailwindCSS + JavaScript
- 현재 기준 버전: `v0.1.42` 준비 중
- 현재 기준 버전: `v0.1.45` 준비 중
- Git 원격 저장소: `https://git.sori.studio/zenn/planner.sori.studio.git`
## 기준 디자인
@@ -53,7 +53,8 @@
- 달력 상단은 월 좌우 화살표, 클릭형 연도 선택, `TODAY` 버튼 구조로 동작한다.
- 입력 내용이 있는 날짜는 달력 하단에 빨간 점으로 표시된다.
- 상단 날짜 표시에서는 토요일의 `(토)`만 파란색, 일요일의 `(일)`만 빨간색으로 표시한다.
- 플래너 상태는 `localStorage`에 저장되며, 날짜별 기록과 선택 날짜, 달력 보고 있던 월까지 복원다.
- 플래너 상태는 `localStorage`에 저장되며, 날짜별 기록과 통계 범위 같은 UI 상태를 복원다.
- 플래너 기록 자체는 로컬에 남기되, 앱을 새로 열 때 기본 기준 날짜는 마지막 열람 날짜가 아니라 항상 오늘 날짜로 맞춘다.
- `localStorage` 접근 로직은 `src/lib/plannerStorage.js`로 분리하기 시작했고, 이후 API/DB adapter로 교체하기 쉬운 구조로 정리 중이다.
- 프론트는 헤더에서 `LOGIN` / `SIGN UP` 모달을 열 수 있고, 로그인 상태면 닉네임과 `LOGOUT` 버튼을 표시한다.
- 인증 토큰과 현재 사용자 정보는 프론트 로컬 저장소에 따로 유지하고, 앱 시작 시 `/api/auth/me`로 세션 복원을 시도한다.
@@ -219,10 +220,23 @@
- 플래너 본문 시간 라벨은 `총 시간`에서 `FOCUSED TIME`으로 바꿨다. 인쇄 CSS에서 COMMENT/FOCUSED TIME 라벨이 잘리지 않도록 부모 overflow를 열고, COMMENT는 남는 폭을 채우며 FOCUSED TIME은 오른쪽 210px 칸에 붙도록 조정했다.
- Docker 배포용 루트 `.env`와 개발용 `.env.dev`를 분리했다. `docker-compose.yml`은 운영 `.env`, `docker-compose.dev.yml`은 기존 dev Postgres 볼륨과 맞는 `.env.dev`를 읽는다.
- STATS의 `RANGE FLOW`는 항목 수에 따라 막대 폭과 간격을 조정한다. 1주일 내외는 넓은 막대로 카드 폭을 채우고, 1달 내외는 좁은 막대와 요약 라벨로 한 화면에서 흐름을 보며, 세부 날짜와 집중 시간은 막대 hover 팝업으로 확인한다.
- 왼쪽 사이드바의 인쇄 영역은 `PRINT` 버튼 하나로 줄이고, 클릭 시 모달에서 시작일/종료일과 `1페이지씩` 또는 `2페이지씩` 출력 방식을 선택한다. 인쇄 전용 렌더링은 선택 기간의 날짜를 순서대로 여러 장 생성하며, 2페이지씩 출력에서 홀수 날짜가 남으면 오른쪽은 빈 페이지 프레임으로 둔다.
- 회원가입과 프로필 수정 시 이메일뿐 아니라 닉네임 중복도 서버에서 409로 막는다. 비밀번호 재설정 API는 로그인 모달의 `비밀번호 찾기` 흐름과 연결되어 있고, `/reset-password?token=...` URL로 들어오면 새 비밀번호 설정 모드가 열린다. 실제 메일 발송 전까지는 백엔드 응답의 `resetPreviewUrl`을 개발용 링크로 표시한다.
- Resend 메일러가 추가되었다. `RESEND_API_KEY`, `MAIL_FROM_EMAIL`, `MAIL_FROM_NAME`, `APP_BASE_URL` 환경변수를 설정하면 이메일 인증과 비밀번호 재설정 메일을 실제로 발송한다. API 키는 저장소에 커밋하지 말고 루트 `.env`/`.env.dev`에만 넣는다.
- 인증/비밀번호 재설정 개발용 링크는 `AUTH_PREVIEW_LINKS=true`일 때만 API 응답에 포함된다. 운영 `.env`는 반드시 `AUTH_PREVIEW_LINKS=false`로 두어야 하며, 현재 예시 파일도 false가 기본값이다.
- 회원가입은 이제 자동 로그인되지 않는다. 인증 메일 발송 후 `이메일 인증 후 로그인` 안내만 보여주고, 일반 사용자는 이메일 인증 전까지 로그인할 수 없다.
- 기존에 발급된 세션이라도 일반 사용자 이메일 인증이 안 되어 있으면 `/api/auth/me` 단계에서 세션을 즉시 폐기한다. 운영 중 인증 정책을 켠 뒤에도 미인증 세션이 남지 않게 하기 위한 장치다.
- 비밀번호 재설정/이메일 인증용 개발 링크는 `AUTH_PREVIEW_LINKS=true`여도 `APP_BASE_URL``localhost` 또는 `127.0.0.1`일 때만 응답에 포함한다. 상용 서버에서 링크가 그대로 보이면 이 조건부터 확인한다.
- 프론트는 `/verify-email?token=...` 진입 시 인증을 바로 확정하고 로그인 모달에 결과 메시지를 띄운다. `/reset-password?token=...`은 기존처럼 비밀번호 재설정 모달을 연다.
- SETTINGS 화면에 일반 사용자 전용 `회원 탈퇴` 카드가 추가되었다. 현재 비밀번호 확인 후 계정, 플래너 기록, 목표, 세션, 인증 토큰이 함께 삭제된다. 기본 관리자 계정은 이 경로에서 삭제하지 못하게 막는다.
- `/api/auth/logout`이 추가되어 로그아웃 시 프론트 저장 토큰만 지우는 것이 아니라 서버 세션도 함께 폐기한다.
- SETTINGS 화면 왼쪽 카드에 현재 기기 로그인 유지 방식(`로그인 유지` 또는 브라우저 세션만 유지), 최근 로그인 시각, 이메일 인증 상태를 보여준다.
- 현재 로그인 유지 방식은 `authPersist` 상태로 함께 들고 가며, 프로필 저장 후에도 원래 저장 방식(localStorage/sessionStorage)을 유지하도록 정리했다.
- `5173` 포트가 직접 `npm run dev` 없이 열려 있으면 대부분 `ten-minute-frontend-dev` 컨테이너가 떠 있는 상태다. 개발용 Docker를 끄려면 `docker compose -f docker-compose.dev.yml down`을 사용한다.
- 현재 환경에서는 Docker 데몬이 꺼져 있어서 `docker compose build` 실검증은 하지 못했고, 데몬 시작 후 다시 확인이 필요하다.
- 이미지 저장 기능은 추후 `print-only` 또는 별도 export 전용 레이아웃을 기준으로 구현하면 화면/인쇄/공유 결과를 맞추기 쉽다.
- Docker Compose는 프론트엔드와 백엔드를 함께 올리는 기준으로 설계하되, NAS 환경에 맞는 볼륨과 재시작 정책도 함께 고려한다.
- Docker Compose 개발/배포 파일에는 `TZ=Asia/Seoul`을 명시해 NAS와 컨테이너 내부 기준 시간이 한국 시간으로 맞도록 유지한다.
- 플래너 본문 라벨은 더 이상 `bg-paper` 배경으로 선을 덮지 않는다. `라벨 + 오른쪽 선` 구조로 바꿔 화면과 인쇄에서 노란 배경이 튀지 않도록 정리했다.
- 날짜에 적용되는 목표가 새로 생기면 D-DAY는 기본 표시된다. 사용자가 해당 날짜에서 직접 `D-DAY 사용`을 끈 경우에만 로컬 숨김 목록에 저장해 다시 숨긴다.
- 비로그인 랜딩은 모바일에서 `카드 안 카드`처럼 보이지 않도록 기능 설명 카드를 얇은 리스트로 단순화했고, `LOGIN` / `SIGN UP` 버튼은 같은 너비와 높이로 맞췄다. 로그인/회원가입 모달도 하단 전환 영역을 별도 카드 대신 구분선 형태로 정리했다.

View File

@@ -61,13 +61,15 @@ docker compose up -d --build
관리자 계정은 백엔드 시작 시 `.env``ADMIN_ACCOUNT_*` 값으로 자동 생성된다.
관리자 아이디와 비밀번호는 저장소 문서에 적지 말고, 운영자만 접근 가능한 비공개 환경변수 파일에서 관리한다.
일반 사용자는 기존처럼 회원가입 후 이메일로 로그인하면 된다.
일반 사용자는 회원가입 후 이메일 인증을 완료해야 로그인할 수 있다.
운영 서버에서는 비밀번호 재설정/이메일 인증용 미리보기 링크가 API 응답에 노출되지 않도록 유지한다.
현재 `docker-compose.yml` 기준 내부 구성:
- 프론트엔드 nginx
- 백엔드 Fastify
- PostgreSQL
- 배포/개발 컨테이너 시간대: `Asia/Seoul`
### 3. 실행 상태 확인하기

23
TODO.md
View File

@@ -51,14 +51,14 @@
## 4단계: 데이터 구조와 저장
- [ ] 플래너 데이터 구조를 날짜별 상태 중심으로 정리한다.
- [x] 플래너 데이터 구조를 날짜별 상태 중심으로 정리한다.
- [x] 입력 데이터의 저장 위치를 결정한다.
- [x] 로컬 저장 또는 외부 저장 방식 중 우선 구현 방식을 정한다.
- [x] 입력 상태가 새로고침 후에도 유지되도록 만든다.
- [x] DB 전환 시점을 잡을 수 있도록 저장 레이어를 분리한다.
- [x] 회원 가입 및 로그인 구조를 고려한 사용자별 데이터 모델을 설계한다.
- [x] 사용자별 문서 저장/조회 흐름을 정리한다.
- [ ] 출력용 문서 포맷과 프린트 흐름을 고려한 데이터 구조를 정리한다.
- [x] 출력용 문서 포맷과 프린트 흐름을 고려한 데이터 구조를 정리한다.
## 추가 반영 메모
@@ -71,7 +71,7 @@
- [x] 통계 페이지 라우팅 또는 화면 전환 구조를 설계한다.
- [x] 집중 시간, 완료율, 연속 기록 같은 핵심 지표를 정의한다.
- [x] 사용자가 시작일과 종료일을 선택해서 기간별 통계를 볼 수 있게 한다.
- [ ] 사용자 개인 통계 화면 기준을 정리한다.
- [x] 사용자 개인 통계 화면 기준을 정리한다.
## 6단계: 계정 및 서비스 확장
@@ -79,8 +79,8 @@
- [x] 사용자 설정 화면에서 닉네임 / 이메일 / 비밀번호 수정 흐름을 분리한다.
- [x] 상단 헤더를 왼쪽 사이드 내비게이션 구조로 재배치한다.
- [x] 본문과 오른쪽 패널이 각각 독립 스크롤되도록 조정한다.
- [ ] 사용자별 문서 분리 저장 구조를 설계한다.
- [ ] 공유가 아닌 개인 보관용 서비스 흐름으로 요구사항을 정리한다.
- [x] 사용자별 문서 분리 저장 구조를 설계한다.
- [x] 공유가 아닌 개인 보관용 서비스 흐름으로 요구사항을 정리한다.
- [x] 향후 출력 기능을 위한 인쇄 레이아웃 요구사항을 정리한다.
- [x] A4 가로 기준 2장 출력 모드를 지원한다.
- [x] `1-UP` 세로 인쇄 / `2-UP` 가로 인쇄 기준을 분리한다.
@@ -94,13 +94,13 @@
- [x] 미완료 항목을 다음 날짜 빈칸으로 이월하는 버튼을 추가한다.
- [x] 이월된 할 일에 배지를 표시하고 원래 시작 날짜를 확인할 수 있게 한다.
- [x] 이월된 할 일을 체크할 때 이전 날짜까지 함께 완료할지 선택하는 정책을 추가한다.
- [ ] 이메일 인증 플로우를 설계하고 구현한다.
- [ ] 비밀번호 찾기 / 재설정 토큰 흐름을 추가한다.
- [x] 이메일 인증 플로우를 설계하고 구현한다.
- [x] 비밀번호 찾기 / 재설정 토큰 흐름을 추가한다.
- [ ] 로그인 및 인증 관련 rate limit / 잠금 정책을 추가한다.
- [x] 로그인 유지 여부를 사용자가 선택할 수 있게 한다.
- [ ] 일정 시간 미사용 시 자동 로그아웃 옵션을 추가한다.
- [ ] 설정 화면에서 현재 기기 로그인 상태와 저장 방식을 안내한다.
- [ ] 서버 세션을 명시적으로 폐기하는 로그아웃 API를 추가한다.
- [x] 설정 화면에서 현재 기기 로그인 상태와 저장 방식을 안내한다.
- [x] 서버 세션을 명시적으로 폐기하는 로그아웃 API를 추가한다.
- [ ] 메일 발송 인프라와 발신 도메인 정책을 확정한다.
- [ ] Resend 무료 플랜 대체 수단으로 SES 또는 일반 SMTP 연동 방식을 확정한다.
- [ ] 관리자 페이지에서 계정 비활성화 / 강제 로그아웃 / 삭제 기능을 추가한다.
@@ -109,12 +109,10 @@
## 메모
- D-DAY는 현재 보류 상태다. 목표 패널 설계 후 연결한다.
- D-DAY는 본문에 직접 입력하는 방식보다, 별도 목표 목록에서 선택한 대표 목표를 보여주는 구조가 더 적합하다.
- 목표가 없는 경우 본문 D-DAY 영역은 숨기고, 오른쪽 패널의 `D-DAY 사용` 메뉴에서 검색/선택하도록 유도한다.
- `TIME TABLE` 드래그는 단순 사각형 선택이 아니라 시간 셀 단위의 연속 선택으로 해석한다.
- 현재는 `localStorage`로 개발을 진행하지만, 적절한 시점에 DB를 붙여 사용자별 저장 구조로 확장해야 한다.
- 현재 `localStorage` 저장 로직은 분리 가능한 형태로 정리 중이며, 이후 API/DB adapter로 교체하기 쉽게 유지한다.
- 로컬 저장은 비로그인/데모 보조 용도로만 남기고, 로그인 상태에서는 사용자별 서버 저장을 우선한다.
- 최종적으로는 회원 가입 후 각자 자신의 문서를 작성/관리하고, 개인 통계를 확인하며, 특정 날짜 문서를 출력할 수 있어야 한다.
- 실제 인쇄는 HTML/CSS 기반 프린트 레이아웃으로 유지하고, 공유용으로는 별도의 이미지 저장 기능을 추가하는 방향이 적합하다.
- 최종 배포는 UGREEN NAS에서 Docker 기반으로 동작할 예정이며, 포트와 실제 서비스 구성은 추후 확정한다.
@@ -134,6 +132,7 @@
- 현재 날짜에 적용된 목표가 있으면 D-DAY는 기본적으로 보이고, 사용자가 해당 날짜에서만 OFF로 끌 수 있다.
- 목표 생성 시 표시 시작일 기본값은 오늘, 표시 종료일 기본값은 목표일로 맞춘다.
- 표시 기간이 다른 진행 중 목표와 겹치면 프론트와 백엔드 모두 저장을 막는다.
- 앱을 새로 열면 마지막 열람 날짜가 아니라 항상 오늘 날짜부터 시작하고, Docker/NAS 컨테이너 시간대는 `Asia/Seoul` 기준으로 맞춘다.
- TASK LABELS는 버튼 묶음 대신 동일한 토글 패턴으로 단순화했다.
- 구현할 때마다 완료된 항목은 체크하고, 큰 결정사항은 `HANDOFF.md`에도 함께 반영한다.
- Resend 무료 플랜은 도메인 수 제약이 있으므로, 실제 인증 메일은 AWS SES 또는 별도 SMTP 서비스 전환을 전제로 설계하는 편이 안전하다.

View File

@@ -14,6 +14,10 @@ const envSchema = z.object({
CORS_ORIGIN: z.string().default('http://localhost:5173'),
SESSION_TTL_DAYS: z.coerce.number().default(30),
APP_BASE_URL: z.string().default('http://localhost:5173'),
RESEND_API_KEY: z.string().optional(),
MAIL_FROM_EMAIL: z.string().email().default('planner@sori.studio'),
MAIL_FROM_NAME: z.string().default('10 Minute Planner'),
AUTH_PREVIEW_LINKS: z.coerce.boolean().default(false),
ADMIN_ACCOUNT_ID: z.string().min(1),
ADMIN_ACCOUNT_PASSWORD: z.string().min(12),
ADMIN_ACCOUNT_EMAIL: z.string().email(),

View File

@@ -14,6 +14,10 @@ function getBearerToken(request) {
return authorization.slice('Bearer '.length).trim()
}
export function getSessionTokenFromRequest(request) {
return getBearerToken(request)
}
export async function createSession(userId) {
const token = createSessionToken()
const tokenHash = hashSessionToken(token)
@@ -61,5 +65,24 @@ export async function findAuthenticatedUser(request) {
.where(eq(users.id, session.userId))
.limit(1)
if (user && user.role !== 'admin' && !user.emailVerifiedAt) {
await db.delete(authSessions).where(eq(authSessions.id, session.id))
return null
}
return user ?? null
}
export async function revokeSessionByToken(token) {
if (!token) {
return false
}
const tokenHash = hashSessionToken(token)
const deletedSessions = await db
.delete(authSessions)
.where(eq(authSessions.tokenHash, tokenHash))
.returning({ id: authSessions.id })
return deletedSessions.length > 0
}

89
backend/src/lib/mailer.js Normal file
View File

@@ -0,0 +1,89 @@
import { env } from '../config.js'
const RESEND_API_URL = 'https://api.resend.com/emails'
function getFromAddress() {
return `${env.MAIL_FROM_NAME} <${env.MAIL_FROM_EMAIL}>`
}
async function sendWithResend({ to, subject, html, text }) {
if (!env.RESEND_API_KEY) {
return {
skipped: true,
reason: 'RESEND_API_KEY is not configured.',
}
}
const response = await fetch(RESEND_API_URL, {
method: 'POST',
headers: {
Authorization: `Bearer ${env.RESEND_API_KEY}`,
'Content-Type': 'application/json',
'User-Agent': 'ten-minute-planner/1.0',
},
body: JSON.stringify({
from: getFromAddress(),
to,
subject,
html,
text,
}),
})
const data = await response.json().catch(() => ({}))
if (!response.ok) {
throw new Error(data.message || data.error?.message || 'Resend 메일 발송에 실패했습니다.')
}
return {
skipped: false,
id: data.id,
}
}
function buildLinkHtml({ title, description, linkUrl, buttonLabel }) {
return `
<div style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: #1c1917; line-height: 1.6;">
<p style="font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase; color: #78716c;">10 Minute Planner</p>
<h1 style="font-size: 24px; margin: 12px 0;">${title}</h1>
<p style="font-size: 15px; color: #57534e;">${description}</p>
<p style="margin: 24px 0;">
<a href="${linkUrl}" style="display: inline-block; border-radius: 999px; background: #1c1917; color: #ffffff; padding: 12px 18px; font-size: 13px; font-weight: 700; text-decoration: none;">
${buttonLabel}
</a>
</p>
<p style="font-size: 12px; color: #78716c;">버튼이 열리지 않으면 아래 링크를 복사해서 브라우저에 붙여넣어 주세요.</p>
<p style="font-size: 12px; word-break: break-all; color: #57534e;">${linkUrl}</p>
<p style="font-size: 12px; color: #a8a29e;">이 링크는 30분 동안 사용할 수 있습니다.</p>
</div>
`
}
export function sendVerificationEmail({ to, linkUrl }) {
return sendWithResend({
to,
subject: '[10 Minute Planner] 이메일 인증',
html: buildLinkHtml({
title: '이메일 인증을 완료해 주세요.',
description: '아래 버튼을 눌러 10 Minute Planner 계정의 이메일 인증을 완료할 수 있습니다.',
linkUrl,
buttonLabel: '이메일 인증하기',
}),
text: `10 Minute Planner 이메일 인증 링크입니다.\n${linkUrl}\n이 링크는 30분 동안 사용할 수 있습니다.`,
})
}
export function sendPasswordResetEmail({ to, linkUrl }) {
return sendWithResend({
to,
subject: '[10 Minute Planner] 비밀번호 재설정',
html: buildLinkHtml({
title: '비밀번호를 재설정해 주세요.',
description: '아래 버튼을 눌러 새 비밀번호를 설정할 수 있습니다. 요청하지 않았다면 이 메일은 무시해 주세요.',
linkUrl,
buttonLabel: '비밀번호 재설정',
}),
text: `10 Minute Planner 비밀번호 재설정 링크입니다.\n${linkUrl}\n요청하지 않았다면 이 메일은 무시해 주세요.`,
})
}

View File

@@ -3,7 +3,8 @@ import { z } from 'zod'
import { db } from '../db/client.js'
import { authSessions, emailVerificationTokens, passwordResetTokens, users } from '../db/schema.js'
import { createSessionToken, hashSessionToken, hashPassword, verifyPassword } from '../lib/password.js'
import { createSession, findAuthenticatedUser } from '../lib/authSession.js'
import { createSession, findAuthenticatedUser, getSessionTokenFromRequest, revokeSessionByToken } from '../lib/authSession.js'
import { sendPasswordResetEmail, sendVerificationEmail } from '../lib/mailer.js'
import { env } from '../config.js'
const signupSchema = z.object({
@@ -27,6 +28,10 @@ const passwordSchema = z.object({
newPassword: z.string().min(8).max(72),
})
const deleteAccountSchema = z.object({
currentPassword: z.string().min(1).max(72),
})
const verificationRequestSchema = z.object({
email: z.string().trim().email().optional(),
})
@@ -108,6 +113,31 @@ function sanitizeUser(user) {
}
}
function withPreviewUrl(payload, key, previewUrl) {
const allowPreviewLinks =
env.AUTH_PREVIEW_LINKS &&
/localhost|127\.0\.0\.1/i.test(env.APP_BASE_URL)
if (!allowPreviewLinks) {
return payload
}
return {
...payload,
[key]: previewUrl,
}
}
async function findUserByNickname(nickname) {
const [user] = await db
.select()
.from(users)
.where(eq(users.nickname, nickname))
.limit(1)
return user ?? null
}
export async function registerAuthRoutes(app) {
app.post('/api/auth/signup', async (request, reply) => {
const payload = signupSchema.safeParse(request.body)
@@ -134,6 +164,14 @@ export async function registerAuthRoutes(app) {
})
}
const existingNicknameUser = await findUserByNickname(nickname)
if (existingNicknameUser) {
return reply.code(409).send({
message: '이미 사용 중인 닉네임입니다.',
})
}
const now = new Date()
const passwordHash = await hashPassword(password)
const [user] = await db
@@ -145,21 +183,22 @@ export async function registerAuthRoutes(app) {
nickname,
role: 'user',
emailVerifiedAt: null,
lastLoginAt: now,
lastLoginAt: null,
createdAt: now,
updatedAt: now,
})
.returning()
const { token } = await createSession(user.id)
const verification = await createEmailVerificationToken(user.id)
return reply.code(201).send({
message: '회원가입이 완료되었습니다.',
token,
user: sanitizeUser(user),
verificationPreviewUrl: verification.previewUrl,
await sendVerificationEmail({
to: user.email,
linkUrl: verification.previewUrl,
})
return reply.code(201).send(withPreviewUrl({
message: '회원가입이 완료되었습니다. 이메일 인증 후 로그인해 주세요.',
requiresEmailVerification: true,
}, 'verificationPreviewUrl', verification.previewUrl))
})
app.post('/api/auth/login', async (request, reply) => {
@@ -200,6 +239,12 @@ export async function registerAuthRoutes(app) {
})
}
if (user.role !== 'admin' && !user.emailVerifiedAt) {
return reply.code(403).send({
message: '이메일 인증을 완료한 뒤 로그인해 주세요.',
})
}
const now = new Date()
const [updatedUser] = await db
@@ -234,6 +279,22 @@ export async function registerAuthRoutes(app) {
}
})
app.post('/api/auth/logout', async (request, reply) => {
const token = getSessionTokenFromRequest(request)
if (!token) {
return reply.code(401).send({
message: '인증이 필요합니다.',
})
}
await revokeSessionByToken(token)
return {
message: '로그아웃되었습니다.',
}
})
app.put('/api/auth/profile', async (request, reply) => {
const user = await findAuthenticatedUser(request)
@@ -266,6 +327,14 @@ export async function registerAuthRoutes(app) {
})
}
const existingNicknameUser = await findUserByNickname(payload.data.nickname)
if (existingNicknameUser && existingNicknameUser.id !== user.id) {
return reply.code(409).send({
message: '이미 사용 중인 닉네임입니다.',
})
}
const [updatedUser] = await db
.update(users)
.set({
@@ -323,6 +392,46 @@ export async function registerAuthRoutes(app) {
}
})
app.delete('/api/auth/account', async (request, reply) => {
const user = await findAuthenticatedUser(request)
if (!user) {
return reply.code(401).send({
message: '인증이 필요합니다.',
})
}
if (user.role === 'admin') {
return reply.code(403).send({
message: '기본 관리자 계정은 여기서 삭제할 수 없습니다.',
})
}
const payload = deleteAccountSchema.safeParse(request.body)
if (!payload.success) {
return reply.code(400).send({
message: '회원 탈퇴 확인 비밀번호를 입력해 주세요.',
issues: payload.error.flatten(),
})
}
const passwordMatches = await verifyPassword(payload.data.currentPassword, user.passwordHash)
if (!passwordMatches) {
return reply.code(401).send({
message: '현재 비밀번호가 올바르지 않습니다.',
})
}
await db.delete(authSessions).where(eq(authSessions.userId, user.id))
await db.delete(users).where(eq(users.id, user.id))
return {
message: '회원 탈퇴가 완료되었습니다.',
}
})
app.post('/api/auth/verification/request', async (request, reply) => {
const authenticatedUser = await findAuthenticatedUser(request)
const payload = verificationRequestSchema.safeParse(request.body ?? {})
@@ -361,11 +470,14 @@ export async function registerAuthRoutes(app) {
}
const verification = await createEmailVerificationToken(user.id)
await sendVerificationEmail({
to: user.email,
linkUrl: verification.previewUrl,
})
return {
return withPreviewUrl({
message: '이메일 인증 링크를 준비했습니다.',
verificationPreviewUrl: verification.previewUrl,
}
}, 'verificationPreviewUrl', verification.previewUrl)
})
app.post('/api/auth/verification/confirm', async (request, reply) => {
@@ -445,11 +557,14 @@ export async function registerAuthRoutes(app) {
}
const reset = await createPasswordResetToken(user.id)
await sendPasswordResetEmail({
to: user.email,
linkUrl: reset.previewUrl,
})
return {
return withPreviewUrl({
message: '비밀번호 재설정 링크를 준비했습니다.',
resetPreviewUrl: reset.previewUrl,
}
}, 'resetPreviewUrl', reset.previewUrl)
})
app.post('/api/auth/password-reset/confirm', async (request, reply) => {

View File

@@ -4,6 +4,8 @@ services:
container_name: ten-minute-postgres-dev
env_file:
- ./.env.dev
environment:
TZ: Asia/Seoul
volumes:
- postgres_dev_data:/var/lib/postgresql/data
ports:
@@ -26,6 +28,7 @@ services:
PORT: 3001
CORS_ORIGIN: http://localhost:5173
SESSION_TTL_DAYS: 30
TZ: Asia/Seoul
volumes:
- ./backend:/app
- backend_node_modules:/app/node_modules
@@ -44,6 +47,7 @@ services:
environment:
VITE_API_BASE_URL: http://localhost:3001
CHOKIDAR_USEPOLLING: "true"
TZ: Asia/Seoul
volumes:
- .:/app
- /app/backend

View File

@@ -4,6 +4,8 @@ services:
container_name: ten-minute-postgres
env_file:
- ./.env
environment:
TZ: Asia/Seoul
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
@@ -25,6 +27,7 @@ services:
PORT: 3001
CORS_ORIGIN: http://localhost:48081
SESSION_TTL_DAYS: 30
TZ: Asia/Seoul
depends_on:
postgres:
condition: service_healthy
@@ -38,6 +41,8 @@ services:
args:
VITE_API_BASE_URL: /api
container_name: ten-minute-frontend
environment:
TZ: Asia/Seoul
depends_on:
- backend
ports:

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "ten-minute-planner",
"version": "0.1.42",
"version": "0.1.45",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "ten-minute-planner",
"version": "0.1.42",
"version": "0.1.45",
"dependencies": {
"vue": "^3.5.13"
},

View File

@@ -1,7 +1,7 @@
{
"name": "ten-minute-planner",
"private": true,
"version": "0.1.42",
"version": "0.1.45",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -11,10 +11,15 @@ import StatsDashboard from './components/StatsDashboard.vue'
import { fetchAdminOverview } from './lib/adminApi'
import {
clearAuthState,
confirmVerification,
deleteAccount,
fetchCurrentUser,
logout as logoutRequest,
confirmPasswordReset,
login,
persistAuthState,
readAuthState,
requestPasswordReset,
signup,
updatePassword,
updateProfile,
@@ -25,7 +30,6 @@ import { deletePlannerEntry, fetchPlannerEntries, savePlannerEntry } from './lib
import {
createInitialPlannerRecords,
persistPlannerState,
readPlannerStorageState,
restorePlannerUiState,
} from './lib/plannerStorage'
@@ -36,6 +40,7 @@ const CARRYOVER_CHECK_POLICIES = ['ask', 'all', 'current']
const screenMode = ref('planner')
const viewMode = ref('focus')
const printLayout = ref('single')
const printDialogOpen = ref(false)
const demoMode = ref(false)
const demoDayOffset = ref(0)
const authDialogOpen = ref(false)
@@ -43,6 +48,7 @@ const authMode = ref('login')
const authBusy = ref(false)
const authMessage = ref('')
const authToken = ref('')
const authPersist = ref(false)
const currentUser = ref(null)
const goals = ref([])
const goalQuery = ref('')
@@ -59,10 +65,15 @@ const leftPanelOpen = ref(false)
const rightPanelOpen = ref(false)
const statsRangeStart = ref(toKey(new Date(new Date().setDate(new Date().getDate() - 6))))
const statsRangeEnd = ref(toKey(new Date()))
const printRangeStart = ref(toKey(new Date()))
const printRangeEnd = ref(toKey(new Date()))
const printRangeLayout = ref('single')
const authForm = reactive({
nickname: '',
email: '',
password: '',
resetToken: '',
newPassword: '',
rememberSession: false,
})
const goalForm = reactive({
@@ -80,10 +91,15 @@ const passwordForm = reactive({
newPassword: '',
confirmPassword: '',
})
const accountDeleteForm = reactive({
currentPassword: '',
})
const profileBusy = ref(false)
const passwordBusy = ref(false)
const profileMessage = ref('')
const passwordMessage = ref('')
const accountDeleteBusy = ref(false)
const accountDeleteMessage = ref('')
const carryoverMessage = ref('')
const carryoverCheckPolicy = ref(readCarryoverCheckPolicy())
const carryoverCheckPrompt = ref(null)
@@ -550,6 +566,56 @@ const calendarDays = computed(() => {
})
})
const normalizedPrintRange = computed(() => {
const startKey = printRangeStart.value || toKey(selectedDate.value)
const endKey = printRangeEnd.value || startKey
if (startKey <= endKey) {
return { startKey, endKey }
}
return { startKey: endKey, endKey: startKey }
})
const printDateKeys = computed(() => {
const dateKeys = []
const currentDate = startOfDay(toDateValue(normalizedPrintRange.value.startKey))
const endDate = startOfDay(toDateValue(normalizedPrintRange.value.endKey))
while (currentDate <= endDate) {
dateKeys.push(toKey(currentDate))
currentDate.setDate(currentDate.getDate() + 1)
}
return dateKeys
})
const printPages = computed(() =>
printDateKeys.value.map((dateKey) => createPrintPage(dateKey)),
)
const printPapers = computed(() => {
if (printLayout.value === 'single') {
return printPages.value.map((page) => [page])
}
const papers = []
for (let index = 0; index < printPages.value.length; index += 2) {
papers.push(printPages.value.slice(index, index + 2))
}
return papers
})
const printPageCountLabel = computed(() => {
const dayCount = printDateKeys.value.length
const paperCount = printRangeLayout.value === 'double' ? Math.ceil(dayCount / 2) : dayCount
const layoutLabel = printRangeLayout.value === 'double' ? '2페이지씩' : '1페이지씩'
return `${dayCount}일치 / ${paperCount}장 (${layoutLabel})`
})
const markedDateKeys = computed(() =>
Object.entries(plannerRecords)
.filter(([, record]) => hasPlannerContent(record))
@@ -558,6 +624,18 @@ const markedDateKeys = computed(() =>
const isAuthenticated = computed(() => Boolean(authToken.value && currentUser.value))
const isAdmin = computed(() => currentUser.value?.role === 'admin')
const authSessionInfo = computed(() => ({
storageLabel: authPersist.value ? '이 기기에서 로그인 유지 중' : '브라우저를 닫으면 로그아웃',
storageDescription: authPersist.value
? '현재 기기에서는 localStorage에 로그인 상태를 저장합니다.'
: '현재 기기에서는 sessionStorage에만 로그인 상태를 유지합니다.',
lastLoginLabel: formatSessionDate(currentUser.value?.lastLoginAt),
verificationLabel: currentUser.value?.role === 'admin'
? '관리자 기본 계정'
: currentUser.value?.emailVerifiedAt
? '이메일 인증 완료'
: '이메일 인증 필요',
}))
const filteredGoals = computed(() => {
const query = goalQuery.value.trim().toLowerCase()
return goals.value.filter((goal) => {
@@ -801,6 +879,12 @@ function closeCarryoverCheckPrompt() {
}
function handleGlobalKeydown(event) {
if (event.key === 'Escape' && printDialogOpen.value) {
event.preventDefault()
closePrintDialog()
return
}
if (event.key === 'Escape' && carryoverCheckPrompt.value) {
event.preventDefault()
closeCarryoverCheckPrompt()
@@ -971,6 +1055,56 @@ function createDateLabel(dateKey) {
return `${display.main} ${display.weekday}`
}
function findPlannerGoalForDate(dateKey) {
const activeGoals = goals.value
.filter((goal) => {
if (!goal.activeFrom || !goal.activeUntil) {
return false
}
return dateKey >= goal.activeFrom && dateKey <= goal.activeUntil
})
.sort((left, right) => {
const currentDate = startOfDay(toDateValue(dateKey))
const leftDistance = Math.abs(startOfDay(toDateValue(left.targetDate)).getTime() - currentDate.getTime())
const rightDistance = Math.abs(startOfDay(toDateValue(right.targetDate)).getTime() - currentDate.getTime())
return leftDistance - rightDistance
})
return activeGoals[0] ?? null
}
function createPlannerDdayForDate(dateKey) {
if (isDdayDisabledForDate(dateKey)) {
return ''
}
const goal = findPlannerGoalForDate(dateKey)
if (!goal) {
return ''
}
const targetDate = startOfDay(toDateValue(goal.targetDate))
const currentDate = startOfDay(toDateValue(dateKey))
const diffDays = Math.round((targetDate.getTime() - currentDate.getTime()) / (24 * 60 * 60 * 1000))
const badge =
diffDays === 0 ? 'D-DAY' : diffDays > 0 ? `D-${diffDays}` : `D+${Math.abs(diffDays)}`
return `${badge} ${goal.title}`
}
function createPrintPage(dateKey) {
const date = toDateValue(dateKey)
return {
key: dateKey,
display: getDateDisplay(date),
record: getPlannerRecord(date),
dday: createPlannerDdayForDate(dateKey),
}
}
const weeklyRecords = computed(() => {
const entries = rangeEntries.value.map(([key, record]) => {
const date = toDateValue(key)
@@ -1211,6 +1345,19 @@ function closeRightPanel() {
rightPanelOpen.value = false
}
function openPrintDialog() {
const selectedKey = toKey(selectedDate.value)
printRangeStart.value = selectedKey
printRangeEnd.value = selectedKey
printRangeLayout.value = viewMode.value === 'spread' ? 'double' : 'single'
printDialogOpen.value = true
closeLeftPanel()
}
function closePrintDialog() {
printDialogOpen.value = false
}
function applyStatsQuickRange(days) {
const endDate = new Date()
const startDate = new Date(endDate)
@@ -1292,6 +1439,8 @@ function resetAuthForm() {
authForm.nickname = ''
authForm.email = ''
authForm.password = ''
authForm.resetToken = ''
authForm.newPassword = ''
authForm.rememberSession = false
}
@@ -1308,18 +1457,96 @@ function syncProfileForm() {
profileForm.email = currentUser.value?.email ?? ''
}
function formatSessionDate(value) {
if (!value) {
return '기록이 없습니다.'
}
const date = new Date(value)
if (Number.isNaN(date.getTime())) {
return '기록이 없습니다.'
}
return `${date.getFullYear()}. ${`${date.getMonth() + 1}`.padStart(2, '0')}. ${`${date.getDate()}`.padStart(2, '0')} ${`${date.getHours()}`.padStart(2, '0')}:${`${date.getMinutes()}`.padStart(2, '0')}`
}
function resetPasswordForm() {
passwordForm.currentPassword = ''
passwordForm.newPassword = ''
passwordForm.confirmPassword = ''
}
function resetAccountDeleteForm() {
accountDeleteForm.currentPassword = ''
}
function openAuthDialog(mode = 'login') {
authMode.value = mode
authMessage.value = ''
authDialogOpen.value = true
}
function openPasswordResetFromUrl() {
if (typeof window === 'undefined') {
return
}
const url = new URL(window.location.href)
if (!url.pathname.includes('reset-password')) {
return
}
const token = url.searchParams.get('token') ?? ''
if (!token) {
return
}
authForm.resetToken = token
authMode.value = 'reset-confirm'
authMessage.value = ''
authDialogOpen.value = true
}
async function openVerificationFromUrl() {
if (typeof window === 'undefined') {
return
}
const url = new URL(window.location.href)
if (!url.pathname.includes('verify-email')) {
return
}
const token = url.searchParams.get('token') ?? ''
if (!token) {
authMode.value = 'login'
authMessage.value = '이메일 인증 링크가 올바르지 않습니다.'
authDialogOpen.value = true
return
}
authBusy.value = true
authMode.value = 'login'
authDialogOpen.value = true
try {
const result = await confirmVerification({ token })
authMessage.value = result.message || '이메일 인증이 완료되었습니다. 이제 로그인할 수 있습니다.'
url.pathname = '/'
url.search = ''
window.history.replaceState({}, '', url.toString())
} catch (error) {
authMessage.value = toUserFacingApiError(error, '이메일 인증 링크를 처리하지 못했습니다.')
} finally {
authBusy.value = false
}
}
function closeAuthDialog() {
authDialogOpen.value = false
authMessage.value = ''
@@ -1332,6 +1559,7 @@ function updateAuthField({ field, value }) {
async function applyAuthSuccess(data, persist = false) {
authToken.value = data.token
authPersist.value = persist
currentUser.value = data.user
setSyncFeedback('cloud', '클라우드 동기화 연결됨')
persistAuthState({
@@ -1351,19 +1579,48 @@ async function submitAuthForm() {
authMessage.value = ''
try {
const result =
authMode.value === 'login'
? await login({
email: authForm.email,
password: authForm.password,
})
: await signup({
nickname: authForm.nickname,
email: authForm.email,
password: authForm.password,
})
if (authMode.value === 'reset-request') {
const result = await requestPasswordReset({
email: authForm.email,
})
authMessage.value = result.resetPreviewUrl
? `${result.message} 개발용 링크: ${result.resetPreviewUrl}`
: result.message
return
}
await applyAuthSuccess(result, authMode.value === 'login' && authForm.rememberSession)
if (authMode.value === 'reset-confirm') {
const result = await confirmPasswordReset({
token: authForm.resetToken,
newPassword: authForm.newPassword,
})
authMode.value = 'login'
authForm.password = ''
authForm.newPassword = ''
authForm.resetToken = ''
authMessage.value = result.message
return
}
const result = authMode.value === 'login'
? await login({
email: authForm.email,
password: authForm.password,
})
: await signup({
nickname: authForm.nickname,
email: authForm.email,
password: authForm.password,
})
if (authMode.value === 'signup') {
authMode.value = 'login'
authForm.password = ''
authMessage.value = result.message
return
}
await applyAuthSuccess(result, authForm.rememberSession)
} catch (error) {
authMessage.value = toUserFacingApiError(error, '인증 처리 중 문제가 발생했습니다.')
} finally {
@@ -1379,6 +1636,7 @@ async function restoreAuthSession() {
}
authToken.value = savedAuth.token
authPersist.value = savedAuth.persist
currentUser.value = savedAuth.user ?? null
try {
@@ -1396,6 +1654,7 @@ async function restoreAuthSession() {
syncProfileForm()
} catch (error) {
authToken.value = ''
authPersist.value = false
currentUser.value = null
setSyncFeedback('local', '로그인 후 클라우드 저장을 사용할 수 있습니다.', {
visible: false,
@@ -1404,9 +1663,10 @@ async function restoreAuthSession() {
}
}
function logout() {
function clearAuthenticatedState() {
clearPendingSyncTimers()
authToken.value = ''
authPersist.value = false
currentUser.value = null
goals.value = []
goalQuery.value = ''
@@ -1414,6 +1674,7 @@ function logout() {
adminMessage.value = ''
adminUsers.value = []
adminRecentLogins.value = []
accountDeleteMessage.value = ''
adminOverview.value = {
totalUsers: 0,
totalAdmins: 0,
@@ -1433,6 +1694,21 @@ function logout() {
restoreLocalPlannerRecords()
resetGoalForm()
resetPasswordForm()
resetAccountDeleteForm()
}
async function logout() {
const token = authToken.value
if (token) {
try {
await logoutRequest(token)
} catch (error) {
console.warn('서버 로그아웃 처리에 실패했습니다.', error)
}
}
clearAuthenticatedState()
}
async function loadAdminDashboard() {
@@ -1632,6 +1908,10 @@ function updatePasswordField({ field, value }) {
passwordForm[field] = value
}
function updateAccountDeleteField({ field, value }) {
accountDeleteForm[field] = value
}
async function submitProfileForm() {
profileBusy.value = true
profileMessage.value = ''
@@ -1646,6 +1926,7 @@ async function submitProfileForm() {
persistAuthState({
token: authToken.value,
user: result.user,
persist: authPersist.value,
})
syncProfileForm()
await loadAdminDashboard()
@@ -1688,6 +1969,36 @@ async function submitPasswordForm() {
}
}
async function submitDeleteAccount() {
if (!accountDeleteForm.currentPassword) {
accountDeleteMessage.value = '회원 탈퇴를 위해 현재 비밀번호를 입력해 주세요.'
return
}
const confirmed = window.confirm('정말로 회원 탈퇴하시겠습니까? 작성한 플래너와 목표 데이터도 함께 삭제됩니다.')
if (!confirmed) {
return
}
accountDeleteBusy.value = true
accountDeleteMessage.value = ''
try {
const result = await deleteAccount(authToken.value, {
currentPassword: accountDeleteForm.currentPassword,
})
resetAccountDeleteForm()
clearAuthenticatedState()
authMessage.value = ''
window.alert(result.message || '회원 탈퇴가 완료되었습니다.')
} catch (error) {
accountDeleteMessage.value = error.message || '회원 탈퇴를 처리하지 못했습니다.'
} finally {
accountDeleteBusy.value = false
}
}
function replacePlannerRecords(nextRecords) {
Object.keys(plannerRecords).forEach((key) => {
delete plannerRecords[key]
@@ -1700,16 +2011,8 @@ function replacePlannerRecords(nextRecords) {
function restoreLocalPlannerRecords() {
replacePlannerRecords(createInitialPlannerRecords(plannerSeed, normalizeRecord))
const savedState = readPlannerStorageState()
if (savedState.selectedDate) {
selectedDate.value = toDateValue(savedState.selectedDate, selectedDate.value)
}
if (savedState.calendarViewDate) {
calendarViewDate.value = toDateValue(savedState.calendarViewDate, selectedDate.value)
}
selectedDate.value = new Date()
calendarViewDate.value = new Date(selectedDate.value)
}
function findRecordKey(record) {
@@ -1845,6 +2148,19 @@ async function printSelectedPlanner(layout = 'single') {
window.print()
}
async function printPlannerRange() {
printLayout.value = printRangeLayout.value
applyPrintPageStyle(printRangeLayout.value)
await nextTick()
window.print()
}
async function initializeAppSession() {
await openVerificationFromUrl()
openPasswordResetFromUrl()
await restoreAuthSession()
}
onMounted(() => {
resetGoalForm()
setSyncFeedback('local', '로그인 후 클라우드 저장을 사용할 수 있습니다.', {
@@ -1853,7 +2169,7 @@ onMounted(() => {
updateWindowWidth()
window.addEventListener('resize', updateWindowWidth)
window.addEventListener('keydown', handleGlobalKeydown)
restoreAuthSession()
initializeAppSession()
})
onBeforeUnmount(() => {
@@ -2058,16 +2374,9 @@ onBeforeUnmount(() => {
<button
type="button"
class="rounded-2xl border border-stone-200 px-4 py-3 text-xs font-bold tracking-[0.14em] text-stone-600 transition hover:border-stone-400 hover:text-ink"
@click="printSelectedPlanner('single')"
@click="openPrintDialog"
>
1 인쇄
</button>
<button
type="button"
class="rounded-2xl border border-stone-200 px-4 py-3 text-xs font-bold tracking-[0.14em] text-stone-600 transition hover:border-stone-400 hover:text-ink"
@click="printSelectedPlanner('double')"
>
2 인쇄
PRINT
</button>
</div>
</section>
@@ -2097,9 +2406,6 @@ onBeforeUnmount(() => {
<div class="overflow-hidden rounded-[28px] border border-stone-200 bg-[linear-gradient(145deg,rgba(255,255,255,0.96),rgba(246,238,228,0.92))] p-5 shadow-[0_18px_40px_rgba(28,25,23,0.06)]">
<div class="flex items-center justify-between gap-3">
<p class="text-[11px] font-bold uppercase tracking-[0.28em] text-stone-500">10 Minute Planner</p>
<span class="rounded-full border border-stone-200 bg-white/80 px-3 py-1 text-[10px] font-bold tracking-[0.18em] text-stone-500">
DAILY FLOW
</span>
</div>
<div class="mt-6 space-y-3">
<h1 class="text-[28px] font-semibold leading-[1.1] tracking-[-0.06em] text-stone-900">
@@ -2226,16 +2532,9 @@ onBeforeUnmount(() => {
<button
type="button"
class="rounded-2xl border border-stone-200 px-4 py-3 text-xs font-bold tracking-[0.14em] text-stone-600 transition hover:border-stone-400 hover:text-ink"
@click="printSelectedPlanner('single')"
@click="openPrintDialog"
>
1 인쇄
</button>
<button
type="button"
class="rounded-2xl border border-stone-200 px-4 py-3 text-xs font-bold tracking-[0.14em] text-stone-600 transition hover:border-stone-400 hover:text-ink"
@click="printSelectedPlanner('double')"
>
2 인쇄
PRINT
</button>
</div>
</section>
@@ -2255,7 +2554,7 @@ onBeforeUnmount(() => {
10 MINITES PLANNER
</h2>
<p class="mx-auto mt-3 max-w-xl text-sm leading-7 text-stone-600 sm:text-base">
장기 목표, , 집중 시간, 짧은 코멘트를 장의 다이어리로 남기고 내일의 작업까지 이어가세요.
장기 목표, , 집중 시간, 짧은 코멘트를 장의 다이어리로 남기고<br />내일의 작업까지 이어가세요.
</p>
</div>
@@ -2796,13 +3095,19 @@ onBeforeUnmount(() => {
:password-busy="passwordBusy"
:profile-message="profileMessage"
:password-message="passwordMessage"
:account-delete-form="accountDeleteForm"
:account-delete-busy="accountDeleteBusy"
:account-delete-message="accountDeleteMessage"
:auth-session-info="authSessionInfo"
:guide-tooltip-reset-message="guideTooltipResetMessage"
:carryover-check-policy="carryoverCheckPolicy"
@update:profile-field="updateProfileField"
@update:password-field="updatePasswordField"
@update:account-delete-field="updateAccountDeleteField"
@update:carryover-check-policy="updateCarryoverCheckPolicy"
@submit:profile="submitProfileForm"
@submit:password="submitPasswordForm"
@submit:delete-account="submitDeleteAccount"
@reset-guide-tooltips="resetGuideTooltips"
/>
@@ -2832,79 +3137,35 @@ onBeforeUnmount(() => {
/>
<section v-if="isAuthenticated" class="print-only">
<div v-if="printLayout === 'single'" class="print-paper print-paper--single">
<div class="print-sheet-frame">
<div
v-for="(paper, paperIndex) in printPapers"
:key="`${printLayout}-${paperIndex}`"
class="print-paper"
:class="printLayout === 'single' ? 'print-paper--single' : 'print-paper--double'"
>
<div
v-for="page in paper"
:key="page.key"
class="print-sheet-frame"
>
<PlannerPage
:date-main="selectedDateDisplay.main"
:date-weekday="selectedDateDisplay.weekday"
:date-weekday-tone="selectedDateDisplay.weekdayTone"
:dday="plannerDday"
:show-dday="showPlannerDday"
:comment="planner.comment"
:total-time="formatTotalTimeKorean(planner)"
:tasks="planner.tasks"
:memo="planner.memo"
:date-main="page.display.main"
:date-weekday="page.display.weekday"
:date-weekday-tone="page.display.weekdayTone"
:dday="page.dday"
:show-dday="Boolean(page.dday)"
:comment="page.record.comment"
:total-time="formatTotalTimeKorean(page.record)"
:tasks="page.record.tasks"
:memo="page.record.memo"
:hours="hours"
:timetable="planner.timetable"
@update:comment="updateComment(planner, $event)"
@update:task-label="updateTaskLabel(planner, $event)"
@update:task-title="updateTaskTitle(planner, $event)"
@toggle:task="toggleTask(planner, $event)"
@clear:tasks="clearTasks(planner, $event)"
@update:memo-label="updateMemoLabel(planner, $event)"
@update:memo="updateMemo(planner, $event)"
@update:timetable="updateTimetable(planner, $event)"
/>
</div>
</div>
<div v-else class="print-paper print-paper--double">
<div class="print-sheet-frame">
<PlannerPage
:date-main="selectedDateDisplay.main"
:date-weekday="selectedDateDisplay.weekday"
:date-weekday-tone="selectedDateDisplay.weekdayTone"
:dday="plannerDday"
:show-dday="showPlannerDday"
:comment="planner.comment"
:total-time="formatTotalTimeKorean(planner)"
:tasks="planner.tasks"
:memo="planner.memo"
:hours="hours"
:timetable="planner.timetable"
@update:comment="updateComment(planner, $event)"
@update:task-label="updateTaskLabel(planner, $event)"
@update:task-title="updateTaskTitle(planner, $event)"
@toggle:task="toggleTask(planner, $event)"
@clear:tasks="clearTasks(planner, $event)"
@update:memo-label="updateMemoLabel(planner, $event)"
@update:memo="updateMemo(planner, $event)"
@update:timetable="updateTimetable(planner, $event)"
/>
</div>
<div class="print-sheet-frame">
<PlannerPage
:date-main="secondaryDateDisplay.main"
:date-weekday="secondaryDateDisplay.weekday"
:date-weekday-tone="secondaryDateDisplay.weekdayTone"
:dday="''"
:show-dday="false"
:comment="secondaryPlanner.comment"
:total-time="formatTotalTimeKorean(secondaryPlanner)"
:tasks="secondaryPlanner.tasks"
:memo="secondaryPlanner.memo"
:hours="hours"
:timetable="secondaryPlanner.timetable"
@update:comment="updateComment(secondaryPlanner, $event)"
@update:task-label="updateTaskLabel(secondaryPlanner, $event)"
@update:task-title="updateTaskTitle(secondaryPlanner, $event)"
@toggle:task="toggleTask(secondaryPlanner, $event)"
@clear:tasks="clearTasks(secondaryPlanner, $event)"
@update:memo-label="updateMemoLabel(secondaryPlanner, $event)"
@update:memo="updateMemo(secondaryPlanner, $event)"
@update:timetable="updateTimetable(secondaryPlanner, $event)"
:timetable="page.record.timetable"
/>
</div>
<div
v-if="printLayout === 'double' && paper.length === 1"
class="print-sheet-frame print-sheet-frame--blank"
/>
</div>
</section>
</div>
@@ -2922,6 +3183,93 @@ onBeforeUnmount(() => {
@update:field="updateAuthField"
/>
<div
v-if="printDialogOpen"
class="print-hidden fixed inset-0 z-50 flex items-center justify-center bg-stone-900/45 px-4 py-6 backdrop-blur-sm"
@click.self="closePrintDialog"
>
<section class="w-full max-w-lg rounded-[30px] border border-white/70 bg-[#f7f2ea] p-5 shadow-[0_24px_80px_rgba(28,25,23,0.2)] sm:p-6">
<div class="flex items-start justify-between gap-4">
<div>
<p class="text-[10px] font-bold uppercase tracking-[0.24em] text-stone-500">Print Planner</p>
<h2 class="mt-3 text-2xl font-semibold tracking-[-0.05em] text-stone-900">
출력할 날짜 범위 선택
</h2>
<p class="mt-3 text-sm font-semibold leading-6 text-stone-600">
선택한 기간을 1페이지씩 또는 2페이지씩 묶어서 바로 출력합니다.
</p>
</div>
<button
type="button"
class="rounded-full border border-stone-200 bg-white px-3 py-2 text-[10px] font-bold tracking-[0.14em] text-stone-500 transition hover:border-stone-400 hover:text-stone-900"
@click="closePrintDialog"
>
CLOSE
</button>
</div>
<div class="mt-6 grid gap-4 sm:grid-cols-2">
<label class="flex flex-col gap-2 text-[11px] font-bold tracking-[0.14em] text-stone-500">
시작일
<input
v-model="printRangeStart"
type="date"
class="rounded-2xl border border-stone-200 bg-white px-4 py-3 text-sm font-semibold text-stone-800 outline-none transition focus:border-stone-400"
/>
</label>
<label class="flex flex-col gap-2 text-[11px] font-bold tracking-[0.14em] text-stone-500">
종료일
<input
v-model="printRangeEnd"
type="date"
class="rounded-2xl border border-stone-200 bg-white px-4 py-3 text-sm font-semibold text-stone-800 outline-none transition focus:border-stone-400"
/>
</label>
</div>
<div class="mt-5 grid gap-2 sm:grid-cols-2">
<button
type="button"
class="rounded-2xl px-4 py-3 text-xs font-bold tracking-[0.14em] transition"
:class="printRangeLayout === 'single' ? 'bg-stone-900 text-white' : 'border border-stone-200 bg-white text-stone-500'"
@click="printRangeLayout = 'single'"
>
1페이지씩
</button>
<button
type="button"
class="rounded-2xl px-4 py-3 text-xs font-bold tracking-[0.14em] transition"
:class="printRangeLayout === 'double' ? 'bg-stone-900 text-white' : 'border border-stone-200 bg-white text-stone-500'"
@click="printRangeLayout = 'double'"
>
2페이지씩
</button>
</div>
<div class="mt-5 rounded-2xl border border-stone-200 bg-white/78 px-4 py-3">
<p class="text-[11px] font-bold tracking-[0.12em] text-stone-500">출력 예정</p>
<p class="mt-1 text-sm font-semibold text-stone-900">{{ printPageCountLabel }}</p>
</div>
<div class="mt-6 grid gap-2 sm:grid-cols-[1fr_auto]">
<button
type="button"
class="rounded-full border border-stone-900 bg-stone-900 px-5 py-3 text-xs font-bold tracking-[0.16em] text-white transition hover:bg-stone-700"
@click="printPlannerRange"
>
PRINT
</button>
<button
type="button"
class="rounded-full border border-stone-300 bg-white px-5 py-3 text-xs font-bold tracking-[0.16em] text-stone-700 transition hover:border-stone-500 hover:text-stone-900"
@click="closePrintDialog"
>
취소
</button>
</div>
</section>
</div>
<div
v-if="carryoverCheckPrompt"
class="fixed inset-0 z-50 flex items-center justify-center bg-stone-900/45 px-4 py-6 backdrop-blur-sm"

View File

@@ -35,6 +35,58 @@ function updateField(field, event) {
value: event.target.type === 'checkbox' ? event.target.checked : event.target.value,
})
}
function getTitle(mode) {
if (mode === 'signup') {
return '회원가입'
}
if (mode === 'reset-request') {
return '비밀번호 찾기'
}
if (mode === 'reset-confirm') {
return '새 비밀번호 설정'
}
return '로그인'
}
function getDescription(mode) {
if (mode === 'signup') {
return '기록을 저장할 계정을 만들어요.'
}
if (mode === 'reset-request') {
return '가입한 이메일로 재설정 링크를 받을 수 있습니다.'
}
if (mode === 'reset-confirm') {
return '메일로 받은 링크의 토큰과 새 비밀번호를 확인합니다.'
}
return '내 플래너를 이어서 열어요.'
}
function getSubmitLabel(mode, busy) {
if (busy) {
return '처리 중...'
}
if (mode === 'signup') {
return '가입하기'
}
if (mode === 'reset-request') {
return '재설정 링크 받기'
}
if (mode === 'reset-confirm') {
return '비밀번호 재설정'
}
return '로그인하기'
}
</script>
<template>
@@ -47,10 +99,10 @@ function updateField(field, event) {
<div>
<p class="text-[10px] font-bold uppercase tracking-[0.24em] text-stone-500">10 Minute Planner</p>
<h2 class="mt-2 text-2xl font-semibold tracking-[-0.04em] text-stone-900">
{{ mode === 'login' ? '로그인' : '회원가입' }}
{{ getTitle(mode) }}
</h2>
<p class="mt-2 text-sm leading-6 text-stone-600">
{{ mode === 'login' ? '내 플래너를 이어서 열어요.' : '기록을 저장할 계정을 만들어요.' }}
{{ getDescription(mode) }}
</p>
</div>
<button
@@ -74,7 +126,7 @@ function updateField(field, event) {
/>
</div>
<div class="space-y-2">
<div v-if="mode !== 'reset-confirm'" class="space-y-2">
<label class="text-[11px] font-bold tracking-[0.16em] text-stone-600">
{{ mode === 'login' ? '이메일 또는 아이디' : '이메일' }}
</label>
@@ -87,7 +139,18 @@ function updateField(field, event) {
/>
</div>
<div class="space-y-2">
<div v-if="mode === 'reset-confirm'" class="space-y-2">
<label class="text-[11px] font-bold tracking-[0.16em] text-stone-600">재설정 토큰</label>
<input
:value="form.resetToken"
type="text"
class="w-full rounded-2xl border border-stone-300 bg-white/90 px-4 py-3 text-sm font-semibold text-stone-800 outline-none transition focus:border-stone-500"
placeholder="메일 링크의 토큰"
@input="updateField('resetToken', $event)"
/>
</div>
<div v-if="mode === 'login' || mode === 'signup'" class="space-y-2">
<label class="text-[11px] font-bold tracking-[0.16em] text-stone-600">비밀번호</label>
<input
:value="form.password"
@@ -98,6 +161,17 @@ function updateField(field, event) {
/>
</div>
<div v-if="mode === 'reset-confirm'" class="space-y-2">
<label class="text-[11px] font-bold tracking-[0.16em] text-stone-600"> 비밀번호</label>
<input
:value="form.newPassword"
type="password"
class="w-full rounded-2xl border border-stone-300 bg-white/90 px-4 py-3 text-sm font-semibold text-stone-800 outline-none transition focus:border-stone-500"
placeholder="8자 이상 입력해 주세요."
@input="updateField('newPassword', $event)"
/>
</div>
<label
v-if="mode === 'login'"
class="-mt-1 flex items-center gap-2 px-1 text-left"
@@ -123,13 +197,22 @@ function updateField(field, event) {
class="w-full rounded-full bg-stone-900 px-5 py-3 text-xs font-bold tracking-[0.18em] text-white transition hover:bg-stone-700 disabled:cursor-not-allowed disabled:bg-stone-400"
:disabled="busy"
>
{{ busy ? '처리 중...' : mode === 'login' ? '로그인하기' : '가입하기' }}
{{ getSubmitLabel(mode, busy) }}
</button>
</form>
<button
v-if="mode === 'login'"
type="button"
class="mt-4 w-full text-center text-xs font-bold tracking-[0.14em] text-stone-500 underline underline-offset-4 transition hover:text-stone-900"
@click="emit('switch-mode', 'reset-request')"
>
비밀번호를 잊으셨나요?
</button>
<div class="mt-5 flex items-center justify-center gap-2 border-t border-stone-300/70 pt-4">
<p class="text-sm font-semibold text-stone-600">
{{ mode === 'login' ? '아직 계정이 나요?' : '이미 계정이 있나요?' }}
{{ mode === 'signup' ? '이미 계정이 나요?' : '계정 화면으로 돌아갈까요?' }}
</p>
<button
type="button"

View File

@@ -14,6 +14,14 @@ const props = defineProps({
type: Object,
required: true,
},
accountDeleteForm: {
type: Object,
required: true,
},
authSessionInfo: {
type: Object,
required: true,
},
profileBusy: {
type: Boolean,
default: false,
@@ -30,6 +38,14 @@ const props = defineProps({
type: String,
default: '',
},
accountDeleteBusy: {
type: Boolean,
default: false,
},
accountDeleteMessage: {
type: String,
default: '',
},
guideTooltipResetMessage: {
type: String,
default: '',
@@ -45,6 +61,8 @@ const emit = defineEmits([
'update:password-field',
'submit:profile',
'submit:password',
'update:account-delete-field',
'submit:delete-account',
'reset-guide-tooltips',
'update:carryover-check-policy',
])
@@ -66,6 +84,13 @@ function updatePasswordField(field, event) {
value: event.target.value,
})
}
function updateAccountDeleteField(field, event) {
emit('update:account-delete-field', {
field,
value: event.target.value,
})
}
</script>
<template>
@@ -130,6 +155,28 @@ function updatePasswordField(field, event) {
</button>
</div>
</div>
<div class="mt-4 rounded-[24px] border border-stone-200 bg-white/80 p-4">
<p class="text-[10px] font-bold tracking-[0.18em] text-stone-500">LOGIN STATUS</p>
<div class="mt-3 space-y-3">
<div class="rounded-2xl border border-stone-200 bg-[#fbf7f0] px-4 py-3">
<p class="text-[10px] font-bold tracking-[0.16em] text-stone-500">현재 기기 저장 방식</p>
<p class="mt-2 text-sm font-semibold leading-6 text-stone-800">{{ authSessionInfo.storageLabel }}</p>
<p class="mt-1 text-xs font-semibold leading-5 text-stone-500">{{ authSessionInfo.storageDescription }}</p>
</div>
<div class="rounded-2xl border border-stone-200 bg-[#fbf7f0] px-4 py-3">
<p class="text-[10px] font-bold tracking-[0.16em] text-stone-500">최근 로그인</p>
<p class="mt-2 text-sm font-semibold leading-6 text-stone-800">{{ authSessionInfo.lastLoginLabel }}</p>
</div>
<div
v-if="authSessionInfo.verificationLabel"
class="rounded-2xl border border-stone-200 bg-[#fbf7f0] px-4 py-3"
>
<p class="text-[10px] font-bold tracking-[0.16em] text-stone-500">이메일 인증</p>
<p class="mt-2 text-sm font-semibold leading-6 text-stone-800">{{ authSessionInfo.verificationLabel }}</p>
</div>
</div>
</div>
</aside>
<div class="grid gap-6">
@@ -219,6 +266,42 @@ function updatePasswordField(field, event) {
{{ passwordBusy ? '변경 중...' : '비밀번호 변경' }}
</button>
</form>
<form
v-if="user.role !== 'admin'"
class="rounded-[28px] border border-rose-200 bg-white/75 p-6"
@submit.prevent="emit('submit:delete-account')"
>
<p class="text-[11px] font-bold uppercase tracking-[0.24em] text-rose-500">Delete Account</p>
<p class="mt-4 text-sm font-semibold leading-6 text-stone-700">
회원 탈퇴를 진행하면 플래너 기록, 목표, 계정 정보가 함께 삭제됩니다.
</p>
<div class="mt-5 space-y-2">
<label class="text-[11px] font-bold tracking-[0.16em] text-stone-600">현재 비밀번호 확인</label>
<input
:value="accountDeleteForm.currentPassword"
type="password"
class="w-full rounded-2xl border border-rose-200 bg-white px-4 py-3 text-sm font-semibold text-stone-800 outline-none transition focus:border-rose-400"
@input="updateAccountDeleteField('currentPassword', $event)"
/>
</div>
<p
v-if="accountDeleteMessage"
class="mt-4 rounded-2xl border border-rose-200 bg-rose-50 px-4 py-3 text-sm font-semibold leading-6 text-rose-700"
>
{{ accountDeleteMessage }}
</p>
<button
type="submit"
class="mt-5 rounded-full border border-rose-500 px-5 py-3 text-xs font-bold tracking-[0.18em] text-rose-600 transition hover:bg-rose-500 hover:text-white disabled:cursor-not-allowed disabled:border-rose-200 disabled:text-rose-300"
:disabled="accountDeleteBusy"
>
{{ accountDeleteBusy ? '처리 중...' : '회원 탈퇴' }}
</button>
</form>
</div>
</section>
</template>

View File

@@ -92,6 +92,13 @@ export async function fetchCurrentUser(token) {
})
}
export async function logout(token) {
return request('/api/auth/logout', {
method: 'POST',
token,
})
}
export async function updateProfile(token, { email, nickname }) {
return request('/api/auth/profile', {
method: 'PUT',
@@ -107,3 +114,32 @@ export async function updatePassword(token, { currentPassword, newPassword }) {
body: { currentPassword, newPassword },
})
}
export async function deleteAccount(token, { currentPassword }) {
return request('/api/auth/account', {
method: 'DELETE',
token,
body: { currentPassword },
})
}
export async function requestPasswordReset({ email }) {
return request('/api/auth/password-reset/request', {
method: 'POST',
body: { email },
})
}
export async function confirmPasswordReset({ token, newPassword }) {
return request('/api/auth/password-reset/confirm', {
method: 'POST',
body: { token, newPassword },
})
}
export async function confirmVerification({ token }) {
return request('/api/auth/verification/confirm', {
method: 'POST',
body: { token },
})
}

View File

@@ -40,16 +40,8 @@ export function restorePlannerUiState({
toDateValue,
}) {
const savedState = readStorageState()
if (savedState.selectedDate) {
selectedDate.value = toDateValue(savedState.selectedDate, selectedDate.value)
}
if (savedState.calendarViewDate) {
calendarViewDate.value = toDateValue(savedState.calendarViewDate, selectedDate.value)
} else {
calendarViewDate.value = new Date(selectedDate.value)
}
selectedDate.value = toDateValue(new Date(), selectedDate.value)
calendarViewDate.value = new Date(selectedDate.value)
if (savedState.statsRangeStart) {
statsRangeStart.value = savedState.statsRangeStart
@@ -75,12 +67,13 @@ export function persistPlannerState({
const previousState = readStorageState()
const nextState = {
...previousState,
selectedDate: selectedDate.toISOString(),
calendarViewDate: calendarViewDate.toISOString(),
statsRangeStart,
statsRangeEnd,
}
delete nextState.selectedDate
delete nextState.calendarViewDate
if (includeRecords) {
nextState.records = Object.fromEntries(
Object.entries(plannerRecords).map(([key, record]) => [

View File

@@ -31,7 +31,7 @@
background: #ffffff !important;
width: auto !important;
height: auto !important;
overflow: hidden !important;
overflow: visible !important;
}
body {
@@ -50,17 +50,11 @@
}
.print-only {
display: flex !important;
display: block !important;
width: 100% !important;
height: 100% !important;
height: auto !important;
margin: 0 !important;
padding: 0 !important;
align-items: center;
justify-content: center;
break-inside: avoid-page;
page-break-inside: avoid;
break-after: avoid-page;
page-break-after: avoid;
}
.print-root {
@@ -79,15 +73,24 @@
justify-content: center;
background: #ffffff !important;
padding: 0;
margin: 0 auto;
overflow: hidden;
break-after: page;
page-break-after: always;
break-inside: avoid-page;
page-break-inside: avoid;
}
.print-paper:last-child {
break-after: avoid-page;
page-break-after: avoid;
}
body[data-print-layout='single'] .print-paper {
width: 204mm;
height: 291mm;
align-items: flex-start;
width: 210mm;
height: 297mm;
align-items: center;
justify-content: center;
padding-top: 3mm;
}
.print-paper--double {
@@ -99,8 +102,8 @@
}
body[data-print-layout='double'] .print-paper {
width: 285mm;
height: 196mm;
width: 297mm;
height: 210mm;
}
body[data-print-layout='single'] .print-paper--single .print-sheet-frame {
@@ -116,6 +119,10 @@
background: #ffffff !important;
}
.print-sheet-frame--blank {
background: #ffffff !important;
}
body[data-print-layout='double'] .print-paper--double .print-sheet-frame {
width: 139mm;
height: 196mm;