feat: forget-password & reset-password added
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
<!doctype html>
|
||||
<html lang="fa">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
<title>بازیابی رمز عبور</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Tahoma', 'IRANYekan', sans-serif;
|
||||
display: flex;
|
||||
min-height: 100vh;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: #f5f7fb;
|
||||
direction: rtl;
|
||||
}
|
||||
.card {
|
||||
background: #fff;
|
||||
padding: 28px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 8px 30px rgba(0,0,0,.06);
|
||||
width: 380px;
|
||||
}
|
||||
input {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
margin: 8px 0;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 6px;
|
||||
}
|
||||
button {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
border: 0;
|
||||
border-radius: 6px;
|
||||
background: #2563eb;
|
||||
color: #fff;
|
||||
font-weight: 600;
|
||||
}
|
||||
.msg {
|
||||
margin-top: 12px;
|
||||
padding: 8px;
|
||||
border-radius: 6px;
|
||||
word-break: break-word;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="card">
|
||||
<h2 style="margin:0 0 8px">بازیابی رمز عبور</h2>
|
||||
<p style="margin:0 0 12px;font-size:13px;color:#555">
|
||||
لطفاً رمز عبور جدید خود را وارد کنید
|
||||
</p>
|
||||
|
||||
<form id="resetForm" autocomplete="off">
|
||||
<input id="email" name="email" type="email" placeholder="ایمیل (خودکار پر شده)" required />
|
||||
<input id="password" name="password" type="password" placeholder="رمز عبور جدید" required />
|
||||
<input id="password_confirmation" name="password_confirmation" type="password" placeholder="تأیید رمز عبور" required />
|
||||
<input id="token" name="token" type="hidden" value="{{ $token }}" />
|
||||
<button type="submit">بازنشانی رمز عبور</button>
|
||||
</form>
|
||||
|
||||
<div id="result" class="msg" style="display:none"></div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.getElementById('resetForm').addEventListener('submit', async function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
const resultEl = document.getElementById('result');
|
||||
resultEl.style.display = 'block';
|
||||
resultEl.style.background = '#fff7ed';
|
||||
resultEl.style.color = '#7c2d12';
|
||||
resultEl.textContent = 'در حال پردازش...';
|
||||
|
||||
const email = document.getElementById('email').value.trim();
|
||||
const password = document.getElementById('password').value;
|
||||
const password_confirmation = document.getElementById('password_confirmation').value;
|
||||
const token = document.getElementById('token').value;
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/auth/reset-password', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ email, token, password, password_confirmation })
|
||||
});
|
||||
|
||||
const json = await res.json();
|
||||
|
||||
if (res.ok) {
|
||||
resultEl.style.background = '#ecfdf5';
|
||||
resultEl.style.color = '#064e3b';
|
||||
resultEl.textContent = 'رمز عبور با موفقیت بازنشانی شد. اکنون میتوانید وارد شوید.';
|
||||
} else {
|
||||
resultEl.style.background = '#fff1f2';
|
||||
resultEl.style.color = '#7f1d1d';
|
||||
if (json.errors) {
|
||||
const first = Object.values(json.errors)[0];
|
||||
resultEl.textContent = Array.isArray(first) ? first[0] : first;
|
||||
} else {
|
||||
resultEl.textContent = json.message || JSON.stringify(json);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
resultEl.style.background = '#fff1f2';
|
||||
resultEl.style.color = '#7f1d1d';
|
||||
resultEl.textContent = 'خطای شبکه.';
|
||||
console.error(err);
|
||||
}
|
||||
});
|
||||
|
||||
const qs = new URLSearchParams(window.location.search);
|
||||
const emailFromQuery = qs.get('email');
|
||||
if (emailFromQuery) document.getElementById('email').value = emailFromQuery;
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user