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
+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"