v0.1.60 - 닉네임 중복 검증과 비밀번호 재설정 연결
This commit is contained in:
74
src/App.vue
74
src/App.vue
@@ -12,9 +12,11 @@ import { fetchAdminOverview } from './lib/adminApi'
|
||||
import {
|
||||
clearAuthState,
|
||||
fetchCurrentUser,
|
||||
confirmPasswordReset,
|
||||
login,
|
||||
persistAuthState,
|
||||
readAuthState,
|
||||
requestPasswordReset,
|
||||
signup,
|
||||
updatePassword,
|
||||
updateProfile,
|
||||
@@ -67,6 +69,8 @@ const authForm = reactive({
|
||||
nickname: '',
|
||||
email: '',
|
||||
password: '',
|
||||
resetToken: '',
|
||||
newPassword: '',
|
||||
rememberSession: false,
|
||||
})
|
||||
const goalForm = reactive({
|
||||
@@ -1415,6 +1419,8 @@ function resetAuthForm() {
|
||||
authForm.nickname = ''
|
||||
authForm.email = ''
|
||||
authForm.password = ''
|
||||
authForm.resetToken = ''
|
||||
authForm.newPassword = ''
|
||||
authForm.rememberSession = false
|
||||
}
|
||||
|
||||
@@ -1443,6 +1449,29 @@ function openAuthDialog(mode = 'login') {
|
||||
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
|
||||
}
|
||||
|
||||
function closeAuthDialog() {
|
||||
authDialogOpen.value = false
|
||||
authMessage.value = ''
|
||||
@@ -1474,17 +1503,39 @@ 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
|
||||
}
|
||||
|
||||
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,
|
||||
})
|
||||
|
||||
await applyAuthSuccess(result, authMode.value === 'login' && authForm.rememberSession)
|
||||
} catch (error) {
|
||||
@@ -1983,6 +2034,7 @@ onMounted(() => {
|
||||
updateWindowWidth()
|
||||
window.addEventListener('resize', updateWindowWidth)
|
||||
window.addEventListener('keydown', handleGlobalKeydown)
|
||||
openPasswordResetFromUrl()
|
||||
restoreAuthSession()
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user