This commit is contained in:
mobin
2026-04-08 07:22:13 +00:00
parent 2adb741dac
commit a6b5f27343
30300 changed files with 134406 additions and 1504 deletions
File diff suppressed because it is too large Load Diff
+103 -58
View File
@@ -2,6 +2,7 @@
<html lang="en" dir="rtl">
<head>
<meta name="csrf-token" content="{{ csrf_token() }}">
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
@@ -256,61 +257,6 @@
</div>
<div style="margin-bottom: 48px;"></div>
{{-- @if(isset($attendance_recorder) and $attendance_recorder == 1 or true)--}}
{{-- @else--}}
{{-- <div class="fixed bottom-0 max-w-[420px] w-full z-20">--}}
{{-- <form id="actionForm" method="POST"--}}
{{-- class="flex justify-around gap-4 items-center px-4 py-1 bg-cyan-500 text-[25px]"--}}
{{-- style="padding: 15px 0 10px 0">--}}
{{-- @csrf--}}
{{-- @if(isset($_COOKIE['token_0']) || isset($_COOKIE['token_1']) || isset($_COOKIE['token_2']))--}}
{{-- <button type="button" onclick="submitForm('up')"><i--}}
{{-- class="fa-solid fa-arrow-up text-white"></i></button>--}}
{{-- @endif--}}
{{-- --}}{{-- attendances list--}}
{{-- @if(isset($_COOKIE['token-0']))--}}
{{-- <button type="button" onclick="submitForm('/back')"><i--}}
{{-- class="fa-solid fa-backward-step text-white"></i>--}}
{{-- </button>--}}
{{-- @endif--}}
{{-- @if(isset($_COOKIE['user_identity']))--}}
{{-- <button type="button" onclick="submitForm('{{route('attendance.show')}}','')"><i--}}
{{-- class="fa-solid fa-clipboard-user text-white"></i></button>--}}
{{-- @endif--}}
{{-- <button type="button" onclick="submitForm('/', 'GET')"><i--}}
{{-- class="fa-solid fa-house text-white"></i></button>--}}
{{-- @if(!request()->is("admin") && (isset($_COOKIE['ad']) && $_COOKIE['ad']==1))--}}
{{-- <button type="button" onclick="submitForm('{{route('admin.dashboard')}}', 'GET')"><i--}}
{{-- class="fa-solid fa-users text-white"></i></button>--}}
{{-- @elseif(request()->is("admin") && (isset($_COOKIE['ad']) && $_COOKIE['ad']==1))--}}
{{-- <button type="button" onclick="submitForm('/', 'GET')"><i--}}
{{-- class="fa-solid fa-users text-white"></i></button>--}}
{{-- @endif--}}
{{-- @if(isset($_COOKIE['user_identity']))--}}
{{-- <button type="button" onclick="submitForm('{{route('user.profile')}}', 'GET')"><i--}}
{{-- class="fa-solid fa-user text-white"></i></button>--}}
{{-- @endif--}}
{{-- </form>--}}
{{-- </div>--}}
{{-- --}}{{-- @endif--}}
{{-- <script>--}}
{{-- function submitForm(action, method = 'POST') {--}}
{{-- const form = document.getElementById('actionForm');--}}
{{-- form.action = `${action}`;--}}
{{-- form.method = method; // Sets method dynamically--}}
{{-- if (method === 'GET') {--}}
{{-- window.location.href = form.action; // Redirect for GET request--}}
{{-- } else {--}}
{{-- form.submit(); // Submit for POST request--}}
{{-- }--}}
{{-- }--}}
{{-- </script>--}}
<?php
@@ -355,9 +301,9 @@
<span>رمز عبور</span>
</label>
<input type="hidden" name="latitude" id="latitude">
<input type="hidden" name="longitude" id="longitude">
<input type="hidden" name="distance" id="distance">
{{-- <input type="hidden" name="provider" id="provider">--}}
{{-- <input type="hidden" name="longitude" id="longitude">--}}
{{-- <input type="hidden" name="distance" id="distance">--}}
<button type="submit" class=" text-white px-4 py-2 rounded bg-cyan-500">
ورود
</button>
@@ -365,6 +311,105 @@
</div>
<button id="fingerprintLoginBtn" type="button">
ورود با اثر انگشت
</button>
<script>
const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
const btn = document.getElementById('fingerprintLoginBtn');
btn.addEventListener('click', async () => {
try {
// 1. گرفتن challenge
const optRes = await fetch('{{ route('fingerprint.login.options') }}', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': csrfToken
},
credentials: 'same-origin'
});
const optJson = await optRes.json();
const publicKey = optJson.publicKey;
// base64url → ArrayBuffer
publicKey.challenge = base64urlToBuffer(publicKey.challenge);
if (publicKey.allowCredentials) {
publicKey.allowCredentials = publicKey.allowCredentials.map(c => ({
...c,
id: base64urlToBuffer(c.id)
}));
}
// 2. درخواست اثر انگشت
const credential = await navigator.credentials.get({
publicKey
});
// 3. ارسال به سرور
const data = {
id: credential.id,
rawId: bufferToBase64url(credential.rawId),
type: credential.type,
response: {
authenticatorData: bufferToBase64url(credential.response.authenticatorData),
clientDataJSON: bufferToBase64url(credential.response.clientDataJSON),
signature: bufferToBase64url(credential.response.signature),
userHandle: credential.response.userHandle
? bufferToBase64url(credential.response.userHandle)
: null
}
};
const verifyRes = await fetch('{{ route('fingerprint.login.verify') }}', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': csrfToken
},
body: JSON.stringify(data),
credentials: 'same-origin'
});
const result = await verifyRes.json();
if (verifyRes.ok) {
alert('ورود موفق');
location.href = '/dashboard'; // مسیر بعد از لاگین
} else {
alert(result.message || 'خطا در ورود');
}
} catch (err) {
console.error(err);
alert('اثر انگشت در این دستگاه یا مرورگر پشتیبانی نمی‌شود');
}
});
function base64urlToBuffer(base64url) {
const padding = '='.repeat((4 - base64url.length % 4) % 4);
const base64 = (base64url + padding).replace(/-/g, '+').replace(/_/g, '/');
const raw = atob(base64);
const buffer = new ArrayBuffer(raw.length);
const view = new Uint8Array(buffer);
for (let i = 0; i < raw.length; i++) view[i] = raw.charCodeAt(i);
return buffer;
}
function bufferToBase64url(buffer) {
const bytes = new Uint8Array(buffer);
let str = '';
for (const b of bytes) str += String.fromCharCode(b);
return btoa(str).replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
}
</script>
<!-- Modals -->
<!-- Modals -->
<div id="modal-container"
+123 -40
View File
@@ -13,57 +13,140 @@
</label>
</div>
@endif
<form action="{{route('edit.profile')}}" method="post" class="grid grid-cols-2 gap-2 justify-items-stretch content-between text-sm indent-2.5 align-middle divide">
{{-- align-center text-sm text-start">--}}
{{-- <div class="grid grid-cols-2 h-64 gap-2 justify-items-stretch content-between text-sm indent-2.5 align-middle divide">--}}
@csrf
<form action="{{route('edit.profile')}}" method="post"
class="grid grid-cols-2 gap-2 justify-items-stretch content-between text-sm indent-2.5 align-middle divide">
{{-- align-center text-sm text-start">--}}
{{-- <div class="grid grid-cols-2 h-64 gap-2 justify-items-stretch content-between text-sm indent-2.5 align-middle divide">--}}
@csrf
<label class="pb-3">نام و نام خانوادگی:</label>
<input type="text" name="name" value="{{ $user->name ?? '' }}"
placeholder="نام و نام خانوادگی"
class="border border-gray-300 rounded-md text-center">
<label class="pb-3">نام و نام خانوادگی:</label>
<input type="text" name="name" value="{{ $user->name ?? '' }}"
placeholder="نام و نام خانوادگی"
class="border border-gray-300 rounded-md text-center">
<label class="pb-3">ایمیل:</label>
<input type="email" name="email" value="{{ $user->email ?? '' }}"
placeholder="ایمیل"
class="border border-gray-300 rounded-md text-center">
<label class="pb-3">ایمیل:</label>
<input type="email" name="email" value="{{ $user->email ?? '' }}"
placeholder="ایمیل"
class="border border-gray-300 rounded-md text-center">
<label class="pb-3">شماره تماس:</label>
<input type="tel" name="number" value="{{ $user->number ?? '' }}"
placeholder="شماره تماس"
pattern="^09\d{9}$"
class="border border-gray-300 rounded-md text-center" required>
<label class="pb-3">شماره تماس:</label>
<input type="tel" name="number" value="{{ $user->number ?? '' }}"
placeholder="شماره تماس"
pattern="^09\d{9}$"
class="border border-gray-300 rounded-md text-center" required>
<label class="pb-3">چت آیدی تلگرام:</label>
<input type="text" pattern="\d+" name="chatid" value="{{ $user->chatid ?? '' }}"
placeholder="چت آیدی تلگرام"
class="border border-gray-300 rounded-md text-center">
<label class="pb-3">چت آیدی تلگرام:</label>
<input type="text" pattern="\d+" name="chatid" value="{{ $user->chatid ?? '' }}"
placeholder="چت آیدی تلگرام"
class="border border-gray-300 rounded-md text-center">
<label class="pb-3">رمز عبور:</label>
<input type="password" name="password" value="{{ $user->password ?? '' }}"
placeholder="رمز عبور"
class="input border border-gray-300 rounded-md text-center">
<input type="password" name="password_confirmation"
placeholder="تکرار رمز عبور"
class="input border border-gray-300 rounded-md text-center col-start-2 min-h-8">
<label class="pb-3">رمز عبور:</label>
<input type="password" name="password" value="{{ $user->password ?? '' }}"
placeholder="رمز عبور"
class="input border border-gray-300 rounded-md text-center">
<input type="password" name="password_confirmation"
placeholder="تکرار رمز عبور"
class="input border border-gray-300 rounded-md text-center col-start-2 min-h-8">
@if(!empty($_COOKIE['ad']) && $_COOKIE['ad'] == 1)
<label class="pb-3">نقش کاربری:</label>
<select name="role" class="border border-gray-300 rounded-md text-center">
<option value="0" {{ $user->is_admin == 0 ? 'selected' : '' }}>کارمند</option>
<option value="1" {{ $user->is_admin == 1 ? 'selected' : '' }}>ادمین</option>
</select>
@endif
<button type="submit"
class="col-span-2 bg-cyan-500 hover:bg-cyan-700 cursor-pointer
@if(!empty($_COOKIE['ad']) && $_COOKIE['ad'] == 1)
<label class="pb-3">نقش کاربری:</label>
<select name="role" class="border border-gray-300 rounded-md text-center">
<option value="0" {{ $user->is_admin == 0 ? 'selected' : '' }}>کارمند</option>
<option value="1" {{ $user->is_admin == 1 ? 'selected' : '' }}>ادمین</option>
</select>
@endif
<button type="submit"
class="col-span-2 bg-cyan-500 hover:bg-cyan-700 cursor-pointer
rounded-xl border border-400 justify-self-center
p-1.5 text-white">
ثبت تغییرات
</button>
{{-- </div>--}}
ثبت تغییرات
</button>
{{-- </div>--}}
</form>
{{-- اضافه کن درست بعد از فرم یا قبل از دکمه submit --}}
<button type="button" id="registerFingerprint" class="...">ثبت اثر انگشت</button>
<script>
function base64urlToBuffer(base64url) {
const padding = '='.repeat((4 - base64url.length % 4) % 4);
const base64 = (base64url + padding).replace(/-/g, '+').replace(/_/g, '/');
const str = atob(base64);
const buf = new ArrayBuffer(str.length);
const view = new Uint8Array(buf);
for (let i = 0; i < str.length; i++) view[i] = str.charCodeAt(i);
return buf;
}
document.getElementById('registerFingerprint').addEventListener('click', async function() {
try {
// 1. گرفتن options از سرور
const res = await fetch("{{ route('fingerprint.register.options') }}", {
method: "POST",
headers: {
"X-CSRF-TOKEN": "{{ csrf_token() }}",
"Accept": "application/json"
}
});
const options = await res.json();
if (!options.publicKey) {
alert(options.error || "خطا در گرفتن options");
return;
}
// ✅ اینجا: تبدیل user.id و challenge به ArrayBuffer
options.publicKey.user.id = base64urlToBuffer(options.publicKey.user.id);
options.publicKey.challenge = base64urlToBuffer(options.publicKey.challenge);
// 2. ایجاد credential
const credential = await navigator.credentials.create({ publicKey: options.publicKey });
// 3. آماده‌سازی payload برای verifyRegister
const payload = {
id: credential.id,
response: {
clientDataJSON: bufferToBase64url(credential.response.clientDataJSON),
attestationObject: bufferToBase64url(credential.response.attestationObject),
publicKey: "" // کنترلر استخراج می‌کنه
},
name: "دستگاه {{ $user->name }}"
};
// 4. ارسال به verifyRegister
const verifyRes = await fetch("{{ route('fingerprint.register.verify') }}", {
method: "POST",
headers: {
"X-CSRF-TOKEN": "{{ csrf_token() }}",
"Content-Type": "application/json",
"Accept": "application/json"
},
body: JSON.stringify(payload)
});
const verifyData = await verifyRes.json();
alert(verifyData.message || "ثبت اثر انگشت انجام شد");
} catch (e) {
console.error(e);
alert("خطا در ثبت اثر انگشت");
}
});
function bufferToBase64url(buffer) {
const bytes = new Uint8Array(buffer);
let str = '';
for (let i = 0; i < bytes.byteLength; i++) str += String.fromCharCode(bytes[i]);
return btoa(str).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
}
</script>
</div>
</div>