feat: 계정정보 단순화 + 구글 계정 이름 변경 허용
- 계정정보: 아이디·가입유형 행 제거 (이름/이메일/권한만), '이름 변경' 버튼 - ProfileEdit: 소셜(구글) 계정은 비밀번호 재인증 없이 바로 이름만 변경 (아이디/이메일 편집/비밀번호 변경 섹션은 LOCAL 전용으로 숨김) - 백엔드 updateProfile 은 provider 무관하게 동작(변경 없음) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
import { reactive, ref, onMounted } from 'vue'
|
||||
import { computed, reactive, ref, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { authApi } from '@/api/authApi'
|
||||
@@ -7,17 +7,22 @@ import { authApi } from '@/api/authApi'
|
||||
const auth = useAuthStore()
|
||||
const router = useRouter()
|
||||
|
||||
const step = ref('verify') // 'verify' → 'edit'
|
||||
// 소셜(구글 등) 계정은 비밀번호가 없어 재인증 없이 이름만 변경
|
||||
const isSocial = computed(() => (auth.user?.provider || 'LOCAL') !== 'LOCAL')
|
||||
|
||||
const step = ref('verify') // 'verify' → 'edit' (소셜은 곧바로 edit)
|
||||
const password = ref('') // verify 단계에서 입력한 현재 비밀번호 (비밀번호 변경 시 재사용)
|
||||
const form = reactive({ name: '', email: '' })
|
||||
const pw = reactive({ next: '', confirm: '' }) // 비밀번호 변경(선택)
|
||||
const pw = reactive({ next: '', confirm: '' }) // 비밀번호 변경(선택, LOCAL 전용)
|
||||
const loading = ref(false)
|
||||
const error = ref('')
|
||||
|
||||
onMounted(() => {
|
||||
// 소셜 계정은 비밀번호 인증 불가 → 계정정보로 돌려보냄
|
||||
if ((auth.user?.provider || 'LOCAL') !== 'LOCAL') {
|
||||
router.replace('/settings/account')
|
||||
// 소셜 계정: 비밀번호 인증 단계 건너뛰고 바로 이름 변경 화면으로
|
||||
if (isSocial.value) {
|
||||
form.name = auth.user?.name || ''
|
||||
form.email = auth.user?.email || ''
|
||||
step.value = 'edit'
|
||||
}
|
||||
})
|
||||
|
||||
@@ -48,13 +53,14 @@ async function save() {
|
||||
error.value = '이름을 입력하세요.'
|
||||
return
|
||||
}
|
||||
const email = form.email.trim()
|
||||
// 소셜 계정은 이메일(구글 제공) 유지, LOCAL 만 폼에서 편집
|
||||
const email = isSocial.value ? (auth.user?.email || null) : (form.email.trim() || null)
|
||||
if (email && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
|
||||
error.value = '이메일 형식이 올바르지 않습니다.'
|
||||
return
|
||||
}
|
||||
// 비밀번호 변경(선택) — 새 비밀번호를 입력한 경우에만 검증/적용
|
||||
const changePw = !!pw.next
|
||||
// 비밀번호 변경(선택, LOCAL 전용) — 새 비밀번호를 입력한 경우에만 검증/적용
|
||||
const changePw = !isSocial.value && !!pw.next
|
||||
if (changePw) {
|
||||
if (pw.next.length < 8 || pw.next.length > 64) {
|
||||
error.value = '새 비밀번호는 8~64자여야 합니다.'
|
||||
@@ -112,7 +118,7 @@ function cancel() {
|
||||
|
||||
<!-- 2단계: 가입정보 변경 -->
|
||||
<form v-else class="card form" @submit.prevent="save">
|
||||
<label class="field">
|
||||
<label v-if="!isSocial" class="field">
|
||||
<span class="flabel">아이디</span>
|
||||
<input :value="auth.user?.loginId" type="text" disabled />
|
||||
<span class="fnote">아이디는 변경할 수 없습니다.</span>
|
||||
@@ -121,21 +127,23 @@ function cancel() {
|
||||
<span class="flabel">이름</span>
|
||||
<input v-model="form.name" type="text" maxlength="100" placeholder="이름" :disabled="loading" />
|
||||
</label>
|
||||
<label class="field">
|
||||
<label v-if="!isSocial" class="field">
|
||||
<span class="flabel">이메일</span>
|
||||
<input v-model="form.email" type="email" maxlength="255" placeholder="이메일 (선택)" :disabled="loading" />
|
||||
</label>
|
||||
|
||||
<hr class="divider" />
|
||||
<p class="section-label">비밀번호 변경 <span class="opt">(변경 시에만 입력)</span></p>
|
||||
<label class="field">
|
||||
<span class="flabel">새 비밀번호</span>
|
||||
<input v-model="pw.next" type="password" autocomplete="new-password" maxlength="64" placeholder="새 비밀번호 (8~64자)" :disabled="loading" />
|
||||
</label>
|
||||
<label class="field">
|
||||
<span class="flabel">새 비밀번호 확인</span>
|
||||
<input v-model="pw.confirm" type="password" autocomplete="new-password" maxlength="64" placeholder="새 비밀번호 확인" :disabled="loading" />
|
||||
</label>
|
||||
<template v-if="!isSocial">
|
||||
<hr class="divider" />
|
||||
<p class="section-label">비밀번호 변경 <span class="opt">(변경 시에만 입력)</span></p>
|
||||
<label class="field">
|
||||
<span class="flabel">새 비밀번호</span>
|
||||
<input v-model="pw.next" type="password" autocomplete="new-password" maxlength="64" placeholder="새 비밀번호 (8~64자)" :disabled="loading" />
|
||||
</label>
|
||||
<label class="field">
|
||||
<span class="flabel">새 비밀번호 확인</span>
|
||||
<input v-model="pw.confirm" type="password" autocomplete="new-password" maxlength="64" placeholder="새 비밀번호 확인" :disabled="loading" />
|
||||
</label>
|
||||
</template>
|
||||
|
||||
<p v-if="error" class="error">{{ error }}</p>
|
||||
<div class="actions">
|
||||
|
||||
Reference in New Issue
Block a user