Go to file
Daffa Aditya Rejasa Ruswanto 453592b5ad migration to pusher 2026-04-28 16:29:07 +07:00
app migration to pusher 2026-04-28 16:29:07 +07:00
bootstrap first commit 2026-03-14 15:16:49 +07:00
config migration to pusher 2026-04-28 16:29:07 +07:00
database first commit 2026-03-14 15:16:49 +07:00
docs first commit 2026-03-14 15:16:49 +07:00
public first commit 2026-03-14 15:16:49 +07:00
resources migration to pusher 2026-04-28 16:29:07 +07:00
routes migration to pusher 2026-04-28 16:29:07 +07:00
storage update 2026-03-19 22:39:57 +07:00
tests first commit 2026-03-14 15:16:49 +07:00
.codex migration to pusher 2026-04-28 16:29:07 +07:00
.editorconfig first commit 2026-03-14 15:16:49 +07:00
.env.example first commit 2026-03-14 15:16:49 +07:00
.gitattributes first commit 2026-03-14 15:16:49 +07:00
.gitignore first commit 2026-03-14 15:16:49 +07:00
README.md first commit 2026-03-14 15:16:49 +07:00
artisan first commit 2026-03-14 15:16:49 +07:00
attendance.json first commit 2026-03-14 15:16:49 +07:00
composer.json first commit 2026-03-14 15:16:49 +07:00
composer.lock first commit 2026-03-14 15:16:49 +07:00
package-lock.json update 2026-03-19 22:39:57 +07:00
package.json first commit 2026-03-14 15:16:49 +07:00
phpunit.xml first commit 2026-03-14 15:16:49 +07:00
vite.config.js first commit 2026-03-14 15:16:49 +07:00

README.md

Laravel Logo

Build Status Total Downloads Latest Stable Version License

About Laravel

Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:

Laravel is accessible, powerful, and provides tools required for large, robust applications.

Learning Laravel

Laravel has the most extensive and thorough documentation and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.

You may also try the Laravel Bootcamp, where you will be guided through building a modern Laravel application from scratch.

If you don't feel like reading, Laracasts can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.

Laravel Sponsors

We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel Partners program.

Premium Partners

Contributing

Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the Laravel documentation.

Code of Conduct

In order to ensure that the Laravel community is welcoming to all, please review and abide by the Code of Conduct.

Security Vulnerabilities

If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via taylor@laravel.com. All security vulnerabilities will be promptly addressed.

License

The Laravel framework is open-sourced software licensed under the MIT license.

Sidak Desa QR Code System

Sistem absensi menggunakan QR Code dengan token dinamis yang berubah secara otomatis.

Fitur

  • QR Code dengan token yang berubah setiap 60 detik
  • Real-time update menggunakan Pusher
  • Anti-replay protection dengan nonce
  • Auto-refresh ketika token expired
  • Force rotation ketika ada scan yang berhasil

Konfigurasi

1. Environment Variables

Tambahkan konfigurasi berikut di file .env:

# Broadcasting (Pusher)
BROADCAST_DRIVER=pusher
PUSHER_APP_KEY=your_pusher_key
PUSHER_APP_SECRET=your_pusher_secret
PUSHER_APP_ID=your_pusher_app_id
PUSHER_APP_CLUSTER=ap1

# Cache (Redis recommended)
CACHE_DRIVER=redis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

2. Pusher Setup

  1. Daftar di Pusher
  2. Buat aplikasi baru
  3. Copy credentials ke file .env
  4. Pastikan channel attendance.session.{sessionId} diizinkan

API Endpoints

QR Code Generation

GET /api/attendance/sessions/{sessionId}/qrcode

QR Code Verification

POST /api/attendance/verify
Content-Type: application/json

{
    "token": "A1B2C3D4",
    "user_id": 123,
    "device_info": "iPhone 12"
}

Force Rotate Token

POST /api/attendance/sessions/{sessionId}/rotate

Halaman QR Code

GET /attendance/sessions/{sessionId}

Cara Kerja

  1. Token Generation: Server generate token baru setiap 60 detik
  2. Auto Refresh: Frontend refresh token 2 detik sebelum expired
  3. Broadcast: Server broadcast token baru ke semua client via Pusher
  4. Verification: Ketika user scan, token divalidasi dan langsung generate token baru
  5. Anti-Replay: Setiap token hanya bisa digunakan sekali dengan nonce

Troubleshooting

QR Code tidak berubah

  1. Cek konfigurasi Pusher di .env
  2. Cek console browser untuk error
  3. Cek log Laravel untuk broadcast error
  4. Pastikan BROADCAST_DRIVER=pusher

Token tidak ter-generate

  1. Cek cache driver (Redis/File)
  2. Cek log Laravel
  3. Test endpoint /api/attendance/sessions/{sessionId}/qrcode

Broadcast tidak berfungsi

  1. Cek koneksi internet
  2. Cek Pusher dashboard untuk error
  3. Cek browser console untuk WebSocket error
  4. Pastikan channel name benar: attendance.session.{sessionId}

Postman Test Gagal (409 Conflict - Replayed)

Masalah: Token yang digunakan sudah expired atau sudah pernah digunakan sebelumnya.

Solusi:

  1. Gunakan token terbaru:

    • Buka halaman test: http://localhost:8000/test-qr
    • Klik "Get Latest Token" untuk mendapatkan token baru
    • Copy token yang muncul di halaman test
    • Gunakan token tersebut di Postman
  2. Test dengan endpoint khusus:

    # Dapatkan token terbaru
    GET http://localhost:8000/api/attendance/sessions/1/latest-token
    
    # Gunakan token yang didapat untuk verify
    POST http://localhost:8000/api/attendance/verify
    {
      "token": "TOKEN_DARI_LATEST_TOKEN",
      "user_id": 123,
      "device_info": "Postman Test"
    }
    
  3. Force rotate token:

    POST http://localhost:8000/api/attendance/sessions/1/rotate
    

Catatan:

  • Token QR berubah setiap 60 detik
  • Setiap token hanya bisa digunakan sekali (anti-replay protection)
  • QR Code akan otomatis generate ulang setelah verifikasi (berhasil atau gagal)
  • Gunakan halaman test untuk monitoring token terbaru

Testing

Manual Test QR Rotation

curl -X POST http://localhost:8000/api/attendance/sessions/1/rotate

Test Verification

curl -X POST http://localhost:8000/api/attendance/verify \
  -H "Content-Type: application/json" \
  -d '{"token":"A1B2C3D4","user_id":123,"device_info":"test"}'

Logs

Sistem akan mencatat log untuk:

  • QR Token generation
  • QR Token verification
  • Broadcast events
  • Error handling

Cek log di storage/logs/laravel.log