ADD:API RESET -request and password and Refresh access token

This commit is contained in:
supalerk-ar66 2026-01-15 11:06:44 +07:00
parent c557c383e3
commit ae771420be
8 changed files with 55 additions and 29 deletions

View file

@ -24,7 +24,25 @@ const forgotForm = reactive({
})
const forgotRules = {
email: { rules: { required: true, email: true }, label: 'อีเมล' }
email: {
rules: {
required: true,
email: true,
custom: (val: string) => /[\u0E00-\u0E7F]/.test(val) ? 'ห้ามใส่ภาษาไทย' : null
},
label: 'อีเมล'
}
}
const handleInput = (val: string) => {
forgotForm.email = val
if (/[\u0E00-\u0E7F]/.test(val)) {
errors.value.email = 'ห้ามใส่ภาษาไทย'
} else {
if (errors.value.email === 'ห้ามใส่ภาษาไทย') {
clearFieldError('email')
}
}
}
const { requestPasswordReset } = useAuth()
@ -68,29 +86,19 @@ const sendResetLink = async () => {
<form v-if="forgotStep === 'initial'" @submit.prevent="sendResetLink">
<p class="text-slate-700 dark:text-slate-400 text-sm mb-6">กรณากรอกอเมลเพอรบลงกเซตรหณผาน</p>
<FormInput
v-model="forgotForm.email"
:model-value="forgotForm.email"
label="อีเมล"
type="email"
placeholder="student@example.com"
:error="errors.email"
required
@update:model-value="clearFieldError('email')"
@update:model-value="handleInput"
/>
<button type="submit" class="btn btn-primary w-full mb-4" :disabled="isLoading">
<LoadingSpinner v-if="isLoading" size="sm" />
<span v-else>ส่งลิงก์รีเซ็ต</span>
</button>
</form>
<!-- Step 2: Success Message -->
<div v-else style="text-align: center;">
<div style="font-size: 40px; margin-bottom: 16px;">📧</div>
<h3 class="font-bold mb-2">งลงกเรยบรอยแล</h3>
<p class="text-sm text-muted mb-6">กรณาตรวจสอบกลองจดหมายในอเมลของคณเพอดำเนนการรเซตรหสผาน</p>
<!-- Simulation: redirect to reset-password for demo -->
<NuxtLink to="/reset-password" class="btn btn-primary w-full mb-4">จำลองการคลกลงก (เพอการสาธ)</NuxtLink>
</div>
<!-- Navigation Links -->
<div class="text-center mt-6">
<NuxtLink to="/auth/login" class="text-sm font-bold text-slate-500 hover:text-slate-800 transition-colors">