ADD:API RESET -request and password and Refresh access token
This commit is contained in:
parent
c557c383e3
commit
ae771420be
8 changed files with 55 additions and 29 deletions
|
|
@ -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">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue