This commit is contained in:
2023-12-03 17:48:11 +05:00
parent 5f506bab65
commit 5e814d89fa
5 changed files with 116 additions and 40 deletions

View File

@@ -40,6 +40,7 @@
class="form-control form-input form-input-bordered w-full"
autofocus=""
>
<input type="hidden" name="step-sms" value="1">
<span id="username-error-box" class="text-red-500 text-italic error-box"></span>
</div>
@@ -48,31 +49,19 @@
<label class="block mb-2" for="verification">
{{ __('Verification code') }}
</label>
<input
class="form-control form-input form-input-bordered w-full"
id="verification"
type="text"
name="verification"
value=""
>
<span id="verification-error-box" class="text-red-500 text-italic error-box"></span>
</div>
<div class="hidden" id="reset-password-container">
<div class="mb-6">
<div class="mb-6" id="password-box">
<label class="block mb-2" for="password">
{{ __('Password') }}
</label>
<input class="form-control form-input form-input-bordered w-full" id="password" type="password" name="password">
</div>
<div class="mb-6">
<div class="mb-6" id="password-confirm-box">
<label class="block mb-2" for="password_confirmation">
{{ __('Confirm Password') }}
</label>
<input class="form-control form-input form-input-bordered w-full" id="password_confirmation" type="password" name="password_confirmation">
</div>
</div>
@@ -91,35 +80,41 @@
<script>
async function resetPassword(event) {
const response = await postData(event.target.action, getFormData(event))
if (response.errors) {
console.log(response.errors);
loopObject(response.errors, item => addValidationClasses(item))
} else {
removeValidationClasess()
if (response.step === 1) {
$_ID('verification-code-box').classList.remove('hidden')
showVerificationCodeBox()
Swal.fire({
title: '{{ __('Verification code') }}',
text: response.message,
icon: 'info'
})
title: '{{ __('Verification code') }}',
text: response.message,
icon: 'info'
})
}
if (response.step === 2) {
$_ID('username-box').classList.add('hidden')
$_ID('verification-code-box').classList.add('hidden')
$_ID('reset-password-container').classList.remove('hidden')
showPasswordBox()
Swal.fire({
title: '{{ __('Reset password') }}',
title: '{{ __('Reset Password') }}',
text: response.message,
icon: 'warning'
})
}
if (response.step === 3) {
await Swal.fire({
title: response.message,
showDenyButton: false,
showCancelButton: false,
})
window.location.href = '{{ route('login') }}'
}
}
}
</script>