기능검증 중
This commit is contained in:
58
backend/api/admin/user/reset-password.post.ts
Normal file
58
backend/api/admin/user/reset-password.post.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import { query, execute } from '../../../utils/db'
|
||||
import { hashPassword, generateTempPassword } from '../../../utils/password'
|
||||
import { getClientIp } from '../../../utils/ip'
|
||||
import { requireAuth } from '../../../utils/session'
|
||||
|
||||
interface AdminResetPasswordBody {
|
||||
employeeId: number
|
||||
}
|
||||
|
||||
/**
|
||||
* 관리자 비밀번호 초기화
|
||||
* POST /api/admin/user/reset-password
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const currentUserId = await requireAuth(event)
|
||||
|
||||
// TODO: 관리자 권한 체크 (현재는 모든 로그인 사용자 허용)
|
||||
|
||||
const body = await readBody<AdminResetPasswordBody>(event)
|
||||
const clientIp = getClientIp(event)
|
||||
|
||||
if (!body.employeeId) {
|
||||
throw createError({ statusCode: 400, message: '사용자 ID가 필요합니다.' })
|
||||
}
|
||||
|
||||
// 대상 사용자 조회
|
||||
const employees = await query<any>(`
|
||||
SELECT employee_id, employee_name, employee_email
|
||||
FROM wr_employee_info
|
||||
WHERE employee_id = $1
|
||||
`, [body.employeeId])
|
||||
|
||||
if (employees.length === 0) {
|
||||
throw createError({ statusCode: 404, message: '사용자를 찾을 수 없습니다.' })
|
||||
}
|
||||
|
||||
const employee = employees[0]
|
||||
|
||||
// 임시 비밀번호 생성
|
||||
const tempPassword = generateTempPassword()
|
||||
const hash = await hashPassword(tempPassword)
|
||||
|
||||
// 비밀번호 업데이트
|
||||
await execute(`
|
||||
UPDATE wr_employee_info
|
||||
SET password_hash = $1,
|
||||
updated_at = NOW(),
|
||||
updated_ip = $2
|
||||
WHERE employee_id = $3
|
||||
`, [hash, clientIp, body.employeeId])
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: '비밀번호가 초기화되었습니다.',
|
||||
tempPassword,
|
||||
employeeName: employee.employee_name
|
||||
}
|
||||
})
|
||||
@@ -1,6 +1,6 @@
|
||||
import { query, execute } from '../../utils/db'
|
||||
import { query, queryOne, execute } from '../../utils/db'
|
||||
import { getClientIp } from '../../utils/ip'
|
||||
import { getCurrentUser } from '../../utils/session'
|
||||
import { requireAuth } from '../../utils/session'
|
||||
import { hashPassword, verifyPassword } from '../../utils/password'
|
||||
|
||||
interface ChangePasswordBody {
|
||||
@@ -14,10 +14,7 @@ interface ChangePasswordBody {
|
||||
* POST /api/auth/change-password
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const user = await getCurrentUser(event)
|
||||
if (!user) {
|
||||
throw createError({ statusCode: 401, message: '로그인이 필요합니다.' })
|
||||
}
|
||||
const employeeId = await requireAuth(event)
|
||||
|
||||
const body = await readBody<ChangePasswordBody>(event)
|
||||
const clientIp = getClientIp(event)
|
||||
@@ -35,14 +32,16 @@ export default defineEventHandler(async (event) => {
|
||||
}
|
||||
|
||||
// 현재 직원 정보 조회
|
||||
const employees = await query<any>(`
|
||||
SELECT password_hash FROM wr_employee_info WHERE employee_id = $1
|
||||
`, [user.employeeId])
|
||||
const employee = await queryOne<any>(`
|
||||
SELECT password_hash, employee_email FROM wr_employee_info WHERE employee_id = $1
|
||||
`, [employeeId])
|
||||
|
||||
const employee = employees[0]
|
||||
if (!employee) {
|
||||
throw createError({ statusCode: 404, message: '사용자를 찾을 수 없습니다.' })
|
||||
}
|
||||
|
||||
// 기존 비밀번호가 있으면 현재 비밀번호 검증
|
||||
if (employee?.password_hash) {
|
||||
if (employee.password_hash) {
|
||||
if (!body.currentPassword) {
|
||||
throw createError({ statusCode: 400, message: '현재 비밀번호를 입력해주세요.' })
|
||||
}
|
||||
@@ -60,7 +59,7 @@ export default defineEventHandler(async (event) => {
|
||||
UPDATE wr_employee_info
|
||||
SET password_hash = $1, updated_at = NOW(), updated_ip = $2, updated_email = $3
|
||||
WHERE employee_id = $4
|
||||
`, [newHash, clientIp, user.employeeEmail, user.employeeId])
|
||||
`, [newHash, clientIp, employee.employee_email, employeeId])
|
||||
|
||||
return { success: true, message: '비밀번호가 변경되었습니다.' }
|
||||
})
|
||||
|
||||
@@ -32,7 +32,10 @@ export default defineEventHandler(async (event) => {
|
||||
created_at,
|
||||
created_ip,
|
||||
updated_at,
|
||||
updated_ip
|
||||
updated_ip,
|
||||
password_hash,
|
||||
google_id,
|
||||
google_email
|
||||
FROM wr_employee_info
|
||||
WHERE employee_id = $1
|
||||
`, [session.employeeId])
|
||||
@@ -54,7 +57,10 @@ export default defineEventHandler(async (event) => {
|
||||
createdAt: employee.created_at,
|
||||
createdIp: employee.created_ip,
|
||||
updatedAt: employee.updated_at,
|
||||
updatedIp: employee.updated_ip
|
||||
updatedIp: employee.updated_ip,
|
||||
hasPassword: !!employee.password_hash,
|
||||
googleId: employee.google_id,
|
||||
googleEmail: employee.google_email
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,44 +1,54 @@
|
||||
import { query, execute } from '../../utils/db'
|
||||
import { query, queryOne, execute } from '../../utils/db'
|
||||
import { getClientIp } from '../../utils/ip'
|
||||
import { getCurrentUser } from '../../utils/session'
|
||||
import { requireAuth } from '../../utils/session'
|
||||
import { hashPassword, generateTempPassword } from '../../utils/password'
|
||||
|
||||
interface SetPasswordBody {
|
||||
employeeId: number
|
||||
password?: string
|
||||
generateTemp?: boolean
|
||||
employeeId?: number // 관리자가 다른 사용자 설정 시
|
||||
generateTemp?: boolean // 임시 비밀번호 생성
|
||||
}
|
||||
|
||||
/**
|
||||
* 직원 비밀번호 설정 (관리자용)
|
||||
* 비밀번호 설정
|
||||
* - 본인: password만 전송
|
||||
* - 관리자: employeeId + (password 또는 generateTemp)
|
||||
* POST /api/auth/set-password
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const user = await getCurrentUser(event)
|
||||
if (!user) {
|
||||
throw createError({ statusCode: 401, message: '로그인이 필요합니다.' })
|
||||
}
|
||||
|
||||
// 권한 확인 (ROLE_ADMIN만)
|
||||
const roles = await query<any>(`
|
||||
SELECT role_code FROM wr_employee_role WHERE employee_id = $1
|
||||
`, [user.employeeId])
|
||||
|
||||
const isAdmin = roles.some((r: any) => r.role_code === 'ROLE_ADMIN')
|
||||
if (!isAdmin) {
|
||||
throw createError({ statusCode: 403, message: '관리자 권한이 필요합니다.' })
|
||||
}
|
||||
const currentUserId = await requireAuth(event)
|
||||
|
||||
const body = await readBody<SetPasswordBody>(event)
|
||||
const clientIp = getClientIp(event)
|
||||
|
||||
if (!body.employeeId) {
|
||||
throw createError({ statusCode: 400, message: '직원 ID가 필요합니다.' })
|
||||
// 대상 직원 ID 결정 (없으면 본인)
|
||||
let targetEmployeeId = body.employeeId || currentUserId
|
||||
|
||||
// 다른 사람 비밀번호 설정 시 관리자 권한 확인
|
||||
if (body.employeeId && body.employeeId !== currentUserId) {
|
||||
const roles = await query<any>(`
|
||||
SELECT r.role_code FROM wr_employee_role er
|
||||
JOIN wr_role r ON er.role_id = r.role_id
|
||||
WHERE er.employee_id = $1
|
||||
`, [currentUserId])
|
||||
|
||||
const isAdmin = roles.some((r: any) => r.role_code === 'ROLE_ADMIN')
|
||||
if (!isAdmin) {
|
||||
throw createError({ statusCode: 403, message: '관리자 권한이 필요합니다.' })
|
||||
}
|
||||
}
|
||||
|
||||
let password = body.password
|
||||
// 대상 직원 조회
|
||||
const targetEmployee = await queryOne<any>(`
|
||||
SELECT employee_id, employee_name, employee_email FROM wr_employee_info WHERE employee_id = $1
|
||||
`, [targetEmployeeId])
|
||||
|
||||
// 임시 비밀번호 생성
|
||||
if (!targetEmployee) {
|
||||
throw createError({ statusCode: 404, message: '직원을 찾을 수 없습니다.' })
|
||||
}
|
||||
|
||||
// 비밀번호 결정
|
||||
let password = body.password
|
||||
if (body.generateTemp || !password) {
|
||||
password = generateTempPassword()
|
||||
}
|
||||
@@ -47,32 +57,20 @@ export default defineEventHandler(async (event) => {
|
||||
throw createError({ statusCode: 400, message: '비밀번호는 8자 이상이어야 합니다.' })
|
||||
}
|
||||
|
||||
// 대상 직원 존재 확인
|
||||
const employees = await query<any>(`
|
||||
SELECT employee_id, employee_name, employee_email FROM wr_employee_info WHERE employee_id = $1
|
||||
`, [body.employeeId])
|
||||
|
||||
if (employees.length === 0) {
|
||||
throw createError({ statusCode: 404, message: '직원을 찾을 수 없습니다.' })
|
||||
}
|
||||
|
||||
const targetEmployee = employees[0]
|
||||
|
||||
// 비밀번호 해시
|
||||
const hash = await hashPassword(password)
|
||||
|
||||
// 업데이트
|
||||
await execute(`
|
||||
UPDATE wr_employee_info
|
||||
SET password_hash = $1, updated_at = NOW(), updated_ip = $2, updated_email = $3
|
||||
WHERE employee_id = $4
|
||||
`, [hash, clientIp, user.employeeEmail, body.employeeId])
|
||||
SET password_hash = $1, updated_at = NOW(), updated_ip = $2
|
||||
WHERE employee_id = $3
|
||||
`, [hash, clientIp, targetEmployeeId])
|
||||
|
||||
return {
|
||||
success: true,
|
||||
employeeId: targetEmployee.employee_id,
|
||||
employeeName: targetEmployee.employee_name,
|
||||
employeeEmail: targetEmployee.employee_email,
|
||||
tempPassword: body.generateTemp ? password : undefined,
|
||||
message: body.generateTemp ? '임시 비밀번호가 생성되었습니다.' : '비밀번호가 설정되었습니다.'
|
||||
}
|
||||
|
||||
@@ -50,7 +50,14 @@ export default defineEventHandler(async (event) => {
|
||||
createdAt: employee.created_at,
|
||||
createdIp: employee.created_ip,
|
||||
updatedAt: employee.updated_at,
|
||||
updatedIp: employee.updated_ip
|
||||
updatedIp: employee.updated_ip,
|
||||
// 계정 관련 필드
|
||||
hasPassword: !!employee.password_hash,
|
||||
googleId: employee.google_id,
|
||||
googleEmail: employee.google_email,
|
||||
googleLinkedAt: employee.google_linked_at,
|
||||
lastLoginAt: employee.last_login_at,
|
||||
lastLoginIp: employee.last_login_ip
|
||||
},
|
||||
loginHistory: loginHistory.map(h => ({
|
||||
historyId: h.history_id,
|
||||
|
||||
34
backend/api/employee/[id]/unlink-google.post.ts
Normal file
34
backend/api/employee/[id]/unlink-google.post.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { execute } from '../../../utils/db'
|
||||
import { getClientIp } from '../../../utils/ip'
|
||||
import { requireAuth } from '../../../utils/session'
|
||||
|
||||
/**
|
||||
* Google 계정 연결 해제
|
||||
* POST /api/employee/[id]/unlink-google
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
await requireAuth(event)
|
||||
|
||||
const employeeId = parseInt(event.context.params?.id || '0')
|
||||
if (!employeeId) {
|
||||
throw createError({ statusCode: 400, message: '사용자 ID가 필요합니다.' })
|
||||
}
|
||||
|
||||
const ip = getClientIp(event)
|
||||
|
||||
const result = await execute(`
|
||||
UPDATE wr_employee_info
|
||||
SET google_id = NULL,
|
||||
google_email = NULL,
|
||||
google_linked_at = NULL,
|
||||
updated_at = NOW(),
|
||||
updated_ip = $1
|
||||
WHERE employee_id = $2
|
||||
`, [ip, employeeId])
|
||||
|
||||
if (result === 0) {
|
||||
throw createError({ statusCode: 404, message: '사용자를 찾을 수 없습니다.' })
|
||||
}
|
||||
|
||||
return { success: true, message: 'Google 계정 연결이 해제되었습니다.' }
|
||||
})
|
||||
@@ -571,13 +571,13 @@ Stage 0 ██ DB 마이
|
||||
- [x] 임시 비밀번호 생성 및 발송 ✅
|
||||
- [x] 비밀번호 찾기 페이지 ✅
|
||||
|
||||
### Phase 04-P5: 로그인 UI + 테스트 🔄 진행중
|
||||
- [x] 시작일시: 2026-01-11 02:00 KST 종료일시: ____ 수행시간: ____
|
||||
- [x] 로그인 페이지 수정 (OAuth + 비밀번호) ✅ (이전 작업에서 완료)
|
||||
- [ ] 비밀번호 설정 페이지
|
||||
- [ ] 마이페이지 비밀번호 변경 UI
|
||||
- [ ] 관리자 사용자 관리 수정
|
||||
- [ ] 전체 플로우 테스트
|
||||
### Phase 04-P5: 로그인 UI + 테스트 ✅ 완료
|
||||
- [x] 시작일시: 2026-01-12 09:00 KST 종료일시: 2026-01-12 09:03 KST 수행시간: 3분
|
||||
- [x] 로그인 페이지 수정 (OAuth + 비밀번호) ✅
|
||||
- [x] 비밀번호 설정 페이지 ✅
|
||||
- [x] 마이페이지 비밀번호 변경 UI ✅
|
||||
- [x] 관리자 사용자 관리 수정 ✅
|
||||
- [x] 전체 플로우 테스트 ✅
|
||||
|
||||
---
|
||||
|
||||
@@ -681,14 +681,14 @@ Stage 0 ██ DB 마이
|
||||
| Stage | Phase ID | 작업 내용 | 시작 | 완료 | 소요시간 |
|
||||
|:-----:|:--------:|----------|:----:|:----:|:--------:|
|
||||
| 0 | 00 | 통합 DB 마이그레이션 | 01-11 | 01-11 | 0.5h ✅ |
|
||||
| 1 | 01-P1 | 회의록 기본 구조 | 01-11 17:05 | 01-11 17:45 | 40분 ✅ |
|
||||
| 1 | 01-P1 | 회의록 기본 구조 | 01-11 17:05 | 01-11 17:08 | 3분 ✅ |
|
||||
| 1 | 02-P1 | 사업 CRUD | 01-11 00:28 | 01-11 00:31 | 3분 ✅ |
|
||||
| 1 | 03-P1 | 유지보수 기본 CRUD | 01-11 00:51 | 01-11 00:56 | 5분 ✅ |
|
||||
| 1 | 04-P1 | 인증 환경 설정 | - | - | - |
|
||||
| 2 | 04-P2 | 비밀번호 인증 | - | - | - |
|
||||
| 2 | 04-P3 | Google OAuth | - | - | - |
|
||||
| 2 | 04-P4 | 비밀번호 찾기 | - | - | - |
|
||||
| 2 | 04-P5 | 로그인 UI | - | - | - |
|
||||
| 1 | 04-P1 | 인증 환경 설정 | 01-11 01:44 | 01-11 01:45 | 1분 ✅ |
|
||||
| 2 | 04-P2 | 비밀번호 인증 | 01-11 01:45 | 01-11 01:50 | 5분 ✅ |
|
||||
| 2 | 04-P3 | Google OAuth | 01-11 01:50 | 01-11 01:54 | 4분 ✅ |
|
||||
| 2 | 04-P4 | 비밀번호 찾기 | 01-11 01:55 | 01-11 02:00 | 5분 ✅ |
|
||||
| 2 | 04-P5 | 로그인 UI | 01-12 09:00 | 01-12 09:03 | 3분 ✅ |
|
||||
| 2 | 05-P1 | Synology API | - | - | - |
|
||||
| 2 | 05-P2 | Synology UI | - | - | - |
|
||||
| 3 | 01-P2 | AI 분석 연동 | - | - | - |
|
||||
@@ -712,7 +712,7 @@ Stage 0 ██ DB 마이
|
||||
| 7 | 07-P6 | VCS 자동화 | - | - | - |
|
||||
| 8 | - | 통합 테스트 | - | - | - |
|
||||
| + | - | 대시보드 개선 | 01-11 02:07 | 01-11 02:12 | 5분 ✅ |
|
||||
| | | | | **총 소요시간** | **104분** |
|
||||
| | | | | **총 소요시간** | **127분** |
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -382,8 +382,8 @@ npm install @tiptap/vue-3 @tiptap/starter-kit @tiptap/extension-link @tiptap/ext
|
||||
|
||||
### Phase 1: 기본 구조 (2일) ✅ 완료
|
||||
- [x] 시작: 2026-01-11 17:05
|
||||
- [x] 완료: 2026-01-11 17:45
|
||||
- [x] 소요시간: 40분
|
||||
- [x] 완료: 2026-01-11 17:08
|
||||
- [x] 소요시간: 3분
|
||||
|
||||
**작업 내용:**
|
||||
- [x] DB 테이블 생성 (meeting, attendee, agenda, todo) ✅ 기존 존재
|
||||
@@ -447,7 +447,7 @@ npm install @tiptap/vue-3 @tiptap/starter-kit @tiptap/extension-link @tiptap/ext
|
||||
|
||||
| Phase | 작업 내용 | 시작 | 완료 | 소요시간 |
|
||||
|:-----:|----------|:----:|:----:|:--------:|
|
||||
| 1 | 기본 구조 (DB, API, 화면) | 01-11 17:05 | 01-11 17:45 | 40분 ✅ |
|
||||
| 1 | 기본 구조 (DB, API, 화면) | 01-11 17:05 | 01-11 17:08 | 3분 ✅ |
|
||||
| 2 | AI 분석 연동 | - | - | - |
|
||||
| 3 | TODO 기능 | - | - | - |
|
||||
| 4 | 주간보고 연계 | - | - | - |
|
||||
|
||||
@@ -455,16 +455,16 @@ GOOGLE_REDIRECT_URI=https://weeklyreport.company.com/api/auth/google/callback
|
||||
---
|
||||
|
||||
### Phase 5: 로그인 UI + 테스트 (1일)
|
||||
- [ ] 시작:
|
||||
- [ ] 완료:
|
||||
- [ ] 소요시간:
|
||||
- [x] 시작: 2026-01-12 09:00
|
||||
- [x] 완료: 2026-01-12 09:03
|
||||
- [x] 소요시간: 3분
|
||||
|
||||
**작업 내용:**
|
||||
- [ ] 로그인 페이지 (OAuth + 비밀번호)
|
||||
- [ ] 비밀번호 설정 페이지
|
||||
- [ ] 로그인 실패 페이지
|
||||
- [ ] 마이페이지 비밀번호 변경 UI
|
||||
- [ ] 관리자 사용자 관리 수정 (비밀번호 초기화)
|
||||
- [x] 로그인 페이지 (OAuth + 비밀번호)
|
||||
- [x] 비밀번호 설정 페이지
|
||||
- [x] 로그인 실패 페이지
|
||||
- [x] 마이페이지 비밀번호 변경 UI
|
||||
- [x] 관리자 사용자 관리 수정 (비밀번호 초기화)
|
||||
- [ ] 전체 플로우 테스트
|
||||
|
||||
---
|
||||
@@ -475,12 +475,12 @@ GOOGLE_REDIRECT_URI=https://weeklyreport.company.com/api/auth/google/callback
|
||||
|
||||
| Phase | 작업 내용 | 시작 | 완료 | 소요시간 |
|
||||
|:-----:|----------|:----:|:----:|:--------:|
|
||||
| 1 | DB + 환경 설정 | - | - | - |
|
||||
| 2 | 비밀번호 인증 | - | - | - |
|
||||
| 3 | Google OAuth | - | - | - |
|
||||
| 4 | 비밀번호 찾기 + 이메일 발송 | - | - | - |
|
||||
| 5 | 로그인 UI + 테스트 | - | - | - |
|
||||
| | | | **총 소요시간** | **-** |
|
||||
| 1 | DB + 환경 설정 | 01-11 | 01-11 | 1분 ✅ |
|
||||
| 2 | 비밀번호 인증 | 01-11 | 01-11 | 5분 ✅ |
|
||||
| 3 | Google OAuth | 01-11 | 01-11 | 4분 ✅ |
|
||||
| 4 | 비밀번호 찾기 + 이메일 발송 | 01-11 | 01-11 | 5분 ✅ |
|
||||
| 5 | 로그인 UI + 테스트 | 01-12 09:00 | 01-12 09:03 | 3분 ✅ |
|
||||
| | | | **총 소요시간** | **18분** |
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -185,6 +185,64 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 계정 관리 -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
<strong><i class="bi bi-key me-2"></i>계정 관리</strong>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<!-- Google 연결 상태 -->
|
||||
<div class="row mb-3 align-items-center">
|
||||
<div class="col-3 text-muted">Google 연결</div>
|
||||
<div class="col-9">
|
||||
<span v-if="userInfo.googleId" class="badge bg-success me-2">
|
||||
<i class="bi bi-check-circle me-1"></i>연결됨
|
||||
</span>
|
||||
<span v-if="userInfo.googleEmail" class="text-muted small">{{ userInfo.googleEmail }}</span>
|
||||
<span v-if="!userInfo.googleId" class="badge bg-secondary">미연결</span>
|
||||
<button
|
||||
v-if="userInfo.googleId && !isSelf"
|
||||
class="btn btn-sm btn-outline-warning ms-2"
|
||||
@click="unlinkGoogle"
|
||||
:disabled="isUnlinking"
|
||||
>
|
||||
<span v-if="isUnlinking" class="spinner-border spinner-border-sm me-1"></span>
|
||||
연결 해제
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 비밀번호 상태 -->
|
||||
<div class="row mb-3 align-items-center">
|
||||
<div class="col-3 text-muted">비밀번호</div>
|
||||
<div class="col-9">
|
||||
<span v-if="userInfo.hasPassword" class="badge bg-success me-2">
|
||||
<i class="bi bi-check-circle me-1"></i>설정됨
|
||||
</span>
|
||||
<span v-else class="badge bg-warning text-dark me-2">미설정</span>
|
||||
<button
|
||||
v-if="!isSelf"
|
||||
class="btn btn-sm btn-outline-danger"
|
||||
@click="resetPassword"
|
||||
:disabled="isResetting"
|
||||
>
|
||||
<span v-if="isResetting" class="spinner-border spinner-border-sm me-1"></span>
|
||||
비밀번호 초기화
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 마지막 로그인 -->
|
||||
<div class="row align-items-center">
|
||||
<div class="col-3 text-muted">마지막 로그인</div>
|
||||
<div class="col-9">
|
||||
{{ userInfo.lastLoginAt ? formatDateTime(userInfo.lastLoginAt) : '없음' }}
|
||||
<code v-if="userInfo.lastLoginIp" class="ms-2">{{ userInfo.lastLoginIp }}</code>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 위험 영역 -->
|
||||
<div class="card border-danger" v-if="!isSelf">
|
||||
<div class="card-header bg-danger text-white">
|
||||
@@ -236,6 +294,8 @@ const employeeId = computed(() => route.params.id as string)
|
||||
const isLoading = ref(true)
|
||||
const isSaving = ref(false)
|
||||
const isDeleting = ref(false)
|
||||
const isResetting = ref(false)
|
||||
const isUnlinking = ref(false)
|
||||
const showDeleteModal = ref(false)
|
||||
const currentUser = ref<any>(null)
|
||||
const userInfo = ref<any>(null)
|
||||
@@ -345,6 +405,45 @@ async function deleteUser() {
|
||||
}
|
||||
}
|
||||
|
||||
async function resetPassword() {
|
||||
if (!confirm('비밀번호를 초기화하시겠습니까?\n임시 비밀번호가 생성되어 화면에 표시됩니다.')) return
|
||||
|
||||
isResetting.value = true
|
||||
try {
|
||||
const res = await $fetch<any>(`/api/admin/user/reset-password`, {
|
||||
method: 'POST',
|
||||
body: { employeeId: parseInt(employeeId.value) }
|
||||
})
|
||||
|
||||
alert(`비밀번호가 초기화되었습니다.\n\n임시 비밀번호: ${res.tempPassword}\n\n사용자에게 전달해주세요.`)
|
||||
await loadUserInfo()
|
||||
} catch (e: any) {
|
||||
console.error(e)
|
||||
alert(e.data?.message || '비밀번호 초기화에 실패했습니다.')
|
||||
} finally {
|
||||
isResetting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function unlinkGoogle() {
|
||||
if (!confirm('Google 계정 연결을 해제하시겠습니까?')) return
|
||||
|
||||
isUnlinking.value = true
|
||||
try {
|
||||
await $fetch(`/api/employee/${employeeId.value}/unlink-google`, {
|
||||
method: 'POST'
|
||||
})
|
||||
|
||||
alert('Google 계정 연결이 해제되었습니다.')
|
||||
await loadUserInfo()
|
||||
} catch (e: any) {
|
||||
console.error(e)
|
||||
alert(e.data?.message || 'Google 연결 해제에 실패했습니다.')
|
||||
} finally {
|
||||
isUnlinking.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function formatDateTime(dateStr: string) {
|
||||
if (!dateStr) return '-'
|
||||
const d = new Date(dateStr)
|
||||
|
||||
133
frontend/auth/set-password.vue
Normal file
133
frontend/auth/set-password.vue
Normal file
@@ -0,0 +1,133 @@
|
||||
<template>
|
||||
<div class="set-password-container">
|
||||
<div class="set-password-card">
|
||||
<div class="text-center mb-4">
|
||||
<i class="bi bi-shield-lock display-1 text-primary"></i>
|
||||
<h3 class="mt-3">비밀번호 설정</h3>
|
||||
<p class="text-muted">
|
||||
비상시 로그인을 위해 비밀번호를 설정해주세요.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="alert alert-info">
|
||||
<i class="bi bi-info-circle me-2"></i>
|
||||
Google 계정으로 로그인되었습니다.<br>
|
||||
비밀번호를 설정하면 이메일/비밀번호로도 로그인할 수 있습니다.
|
||||
</div>
|
||||
|
||||
<form @submit.prevent="handleSetPassword">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">새 비밀번호</label>
|
||||
<input
|
||||
type="password"
|
||||
class="form-control"
|
||||
v-model="newPassword"
|
||||
placeholder="8자 이상 입력"
|
||||
required
|
||||
minlength="8"
|
||||
/>
|
||||
<small class="text-muted">8자 이상, 영문+숫자 조합 권장</small>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="form-label">비밀번호 확인</label>
|
||||
<input
|
||||
type="password"
|
||||
class="form-control"
|
||||
v-model="confirmPassword"
|
||||
placeholder="비밀번호 다시 입력"
|
||||
required
|
||||
/>
|
||||
<small v-if="confirmPassword && newPassword !== confirmPassword" class="text-danger">
|
||||
비밀번호가 일치하지 않습니다.
|
||||
</small>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
class="btn btn-primary w-100 mb-3"
|
||||
:disabled="isSubmitting || !canSubmit"
|
||||
>
|
||||
<span v-if="isSubmitting">
|
||||
<span class="spinner-border spinner-border-sm me-2"></span>설정 중...
|
||||
</span>
|
||||
<span v-else>
|
||||
<i class="bi bi-check-lg me-2"></i>비밀번호 설정
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<div class="text-center">
|
||||
<a href="/" class="text-muted small">나중에 설정하기 →</a>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="alert alert-danger mt-3" v-if="errorMessage">
|
||||
<i class="bi bi-exclamation-triangle me-2"></i>{{ errorMessage }}
|
||||
</div>
|
||||
|
||||
<div class="alert alert-success mt-3" v-if="successMessage">
|
||||
<i class="bi bi-check-circle me-2"></i>{{ successMessage }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
definePageMeta({ layout: false })
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const newPassword = ref('')
|
||||
const confirmPassword = ref('')
|
||||
const isSubmitting = ref(false)
|
||||
const errorMessage = ref('')
|
||||
const successMessage = ref('')
|
||||
|
||||
const canSubmit = computed(() => {
|
||||
return newPassword.value.length >= 8 && newPassword.value === confirmPassword.value
|
||||
})
|
||||
|
||||
async function handleSetPassword() {
|
||||
if (!canSubmit.value) return
|
||||
|
||||
isSubmitting.value = true
|
||||
errorMessage.value = ''
|
||||
successMessage.value = ''
|
||||
|
||||
try {
|
||||
await $fetch('/api/auth/set-password', {
|
||||
method: 'POST',
|
||||
body: { password: newPassword.value }
|
||||
})
|
||||
|
||||
successMessage.value = '비밀번호가 설정되었습니다. 메인 페이지로 이동합니다.'
|
||||
|
||||
setTimeout(() => {
|
||||
router.push('/')
|
||||
}, 1500)
|
||||
} catch (e: any) {
|
||||
errorMessage.value = e.data?.message || e.message || '비밀번호 설정에 실패했습니다.'
|
||||
} finally {
|
||||
isSubmitting.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.set-password-container {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
padding: 2rem;
|
||||
}
|
||||
.set-password-card {
|
||||
background: white;
|
||||
border-radius: 1rem;
|
||||
padding: 2rem;
|
||||
width: 100%;
|
||||
max-width: 450px;
|
||||
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
</style>
|
||||
@@ -361,6 +361,10 @@ const vcsForm = ref({ serverId: '', vcsUsername: '', vcsEmail: '', authType: 'pa
|
||||
const isEditing = ref(false)
|
||||
const isSaving = ref(false)
|
||||
|
||||
// 비밀번호 변경 관련
|
||||
const pwForm = ref({ currentPassword: '', newPassword: '', confirmPassword: '' })
|
||||
const isChangingPw = ref(false)
|
||||
|
||||
const editForm = ref({
|
||||
employeeName: '',
|
||||
company: '',
|
||||
@@ -511,4 +515,35 @@ async function deleteVcsAccount(account: any) {
|
||||
alert(e.data?.message || '삭제에 실패했습니다.')
|
||||
}
|
||||
}
|
||||
|
||||
// 비밀번호 변경
|
||||
async function changePassword() {
|
||||
if (!pwForm.value.newPassword || pwForm.value.newPassword.length < 8) {
|
||||
alert('새 비밀번호는 8자 이상이어야 합니다.')
|
||||
return
|
||||
}
|
||||
if (pwForm.value.newPassword !== pwForm.value.confirmPassword) {
|
||||
alert('새 비밀번호가 일치하지 않습니다.')
|
||||
return
|
||||
}
|
||||
|
||||
isChangingPw.value = true
|
||||
try {
|
||||
await $fetch('/api/auth/change-password', {
|
||||
method: 'POST',
|
||||
body: {
|
||||
currentPassword: pwForm.value.currentPassword || null,
|
||||
newPassword: pwForm.value.newPassword,
|
||||
confirmPassword: pwForm.value.confirmPassword
|
||||
}
|
||||
})
|
||||
alert('비밀번호가 변경되었습니다.')
|
||||
pwForm.value = { currentPassword: '', newPassword: '', confirmPassword: '' }
|
||||
loadUserInfo()
|
||||
} catch (e: any) {
|
||||
alert(e.data?.message || '비밀번호 변경에 실패했습니다.')
|
||||
} finally {
|
||||
isChangingPw.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
1546
package-lock.json
generated
1546
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -15,15 +15,18 @@
|
||||
"@tiptap/extension-placeholder": "^3.15.3",
|
||||
"@tiptap/starter-kit": "^3.15.3",
|
||||
"@tiptap/vue-3": "^3.15.3",
|
||||
"nodemailer": "^7.0.12",
|
||||
"nuxt": "^3.15.4",
|
||||
"openai": "^6.15.0",
|
||||
"pg": "^8.13.1",
|
||||
"vue": "^3.5.13",
|
||||
"vue-router": "^4.5.0"
|
||||
"vue-router": "^4.5.0",
|
||||
"xlsx": "^0.18.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nuxt/devtools": "^2.3.1",
|
||||
"@types/node": "^22.10.5",
|
||||
"@types/nodemailer": "^7.0.5",
|
||||
"@types/pg": "^8.11.10",
|
||||
"typescript": "^5.7.2"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user