migration to pusher
This commit is contained in:
parent
6f9dde9c38
commit
453592b5ad
|
|
@ -13,6 +13,7 @@
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
|
||||||
class AbsenController extends Controller
|
class AbsenController extends Controller
|
||||||
{
|
{
|
||||||
|
|
@ -23,13 +24,35 @@ private function qrTtl(): int
|
||||||
|
|
||||||
public function verify(Request $req, DynamicQrService $svc)
|
public function verify(Request $req, DynamicQrService $svc)
|
||||||
{
|
{
|
||||||
$req->validate([
|
$req->merge([
|
||||||
|
'latitude' => $req->filled('latitude')
|
||||||
|
? str_replace(',', '.', (string) $req->input('latitude'))
|
||||||
|
: $req->input('latitude'),
|
||||||
|
'longitude' => $req->filled('longitude')
|
||||||
|
? str_replace(',', '.', (string) $req->input('longitude'))
|
||||||
|
: $req->input('longitude'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$validator = Validator::make($req->all(), [
|
||||||
'token' => 'required|string',
|
'token' => 'required|string',
|
||||||
'user_id' => 'required|integer',
|
'user_id' => 'required|integer',
|
||||||
'device_info' => 'nullable|string',
|
'device_info' => 'nullable|string',
|
||||||
'latitude' => 'nullable|numeric|between:-90,90',
|
'latitude' => 'required|numeric|between:-90,90',
|
||||||
'longitude' => 'nullable|numeric|between:-180,180',
|
'longitude' => 'required|numeric|between:-180,180',
|
||||||
|
], [
|
||||||
|
'latitude.numeric' => 'Latitude harus berupa angka yang valid.',
|
||||||
|
'latitude.between' => 'Latitude harus berada di antara -90 sampai 90.',
|
||||||
|
'longitude.numeric' => 'Longitude harus berupa angka yang valid.',
|
||||||
|
'longitude.between' => 'Longitude harus berada di antara -180 sampai 180.',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return response()->json([
|
||||||
|
'ok' => false,
|
||||||
|
'reason' => 'validation_error',
|
||||||
|
'errors' => $validator->errors(),
|
||||||
|
], 422);
|
||||||
|
}
|
||||||
$lat = $req->input('latitude');
|
$lat = $req->input('latitude');
|
||||||
$lng = $req->input('longitude');
|
$lng = $req->input('longitude');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,20 +31,17 @@
|
||||||
'connections' => [
|
'connections' => [
|
||||||
|
|
||||||
'pusher' => [
|
'pusher' => [
|
||||||
'driver' => 'pusher',
|
'driver' => 'pusher',
|
||||||
'key' => env('PUSHER_APP_KEY'),
|
'key' => env('PUSHER_APP_KEY'),
|
||||||
'secret' => env('PUSHER_APP_SECRET'),
|
'secret' => env('PUSHER_APP_SECRET'),
|
||||||
'app_id' => env('PUSHER_APP_ID'),
|
'app_id' => env('PUSHER_APP_ID'),
|
||||||
'options' => [
|
'options' => [
|
||||||
// Pakai cluster hosted Pusher (contoh: ap1)
|
|
||||||
'cluster' => env('PUSHER_APP_CLUSTER'),
|
'cluster' => env('PUSHER_APP_CLUSTER'),
|
||||||
// Force TLS utk hosted Pusher
|
'useTLS' => true,
|
||||||
'useTLS' => env('PUSHER_SCHEME', 'https') === 'https',
|
'host' => env('PUSHER_HOST') ?: 'api-' . env('PUSHER_APP_CLUSTER', 'ap1') . '.pusher.com',
|
||||||
|
'port' => env('PUSHER_PORT', 443),
|
||||||
// Opsi custom host/port (kosongkan jika pakai hosted Pusher)
|
|
||||||
'host' => env('PUSHER_HOST'),
|
|
||||||
'port' => env('PUSHER_PORT', 443),
|
|
||||||
'scheme' => env('PUSHER_SCHEME', 'https'),
|
'scheme' => env('PUSHER_SCHEME', 'https'),
|
||||||
|
'encrypted' => true,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -315,14 +315,12 @@ function patchAttendanceRow(update) {
|
||||||
|
|
||||||
// init Echo Reverb
|
// init Echo Reverb
|
||||||
window.Pusher = window.Pusher || Pusher;
|
window.Pusher = window.Pusher || Pusher;
|
||||||
|
|
||||||
const echo = new window.Echo({
|
const echo = new window.Echo({
|
||||||
broadcaster: 'reverb',
|
broadcaster: 'pusher',
|
||||||
key: "{{ env('REVERB_APP_KEY') }}",
|
key: "{{ env('PUSHER_APP_KEY') }}",
|
||||||
wsHost: "{{ env('REVERB_HOST', '127.0.0.1') }}",
|
cluster: "{{ env('PUSHER_APP_CLUSTER', 'ap1') }}",
|
||||||
wsPort: {{ env('REVERB_PORT', 8080) }},
|
forceTLS: "{{ env('PUSHER_SCHEME', 'https') }}" === 'https',
|
||||||
wssPort: {{ env('REVERB_PORT', 8080) }},
|
|
||||||
forceTLS: "{{ env('REVERB_SCHEME', 'http') }}" === 'https',
|
|
||||||
enabledTransports: ['ws', 'wss'],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
echo.channel('attendance.global')
|
echo.channel('attendance.global')
|
||||||
|
|
|
||||||
|
|
@ -529,13 +529,10 @@ function initializeEcho() {
|
||||||
window.Pusher = window.Pusher || Pusher;
|
window.Pusher = window.Pusher || Pusher;
|
||||||
|
|
||||||
const echo = new window.Echo({
|
const echo = new window.Echo({
|
||||||
broadcaster: 'reverb',
|
broadcaster: 'pusher',
|
||||||
key: "{{ env('REVERB_APP_KEY') }}",
|
key: "{{ env('PUSHER_APP_KEY') }}",
|
||||||
wsHost: "{{ env('REVERB_HOST', '127.0.0.1') }}",
|
cluster: "{{ env('PUSHER_APP_CLUSTER', 'ap1') }}",
|
||||||
wsPort: {{ env('REVERB_PORT', 8080) }},
|
forceTLS: "{{ env('PUSHER_SCHEME', 'https') }}" === 'https',
|
||||||
wssPort: {{ env('REVERB_PORT', 8080) }},
|
|
||||||
forceTLS: "{{ env('REVERB_SCHEME', 'http') }}" === 'https',
|
|
||||||
enabledTransports: ['ws', 'wss'],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
window.echo = echo; // untuk debug
|
window.echo = echo; // untuk debug
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@
|
||||||
Route::get('/', [LandingPageController::class, 'index'])->name('home');
|
Route::get('/', [LandingPageController::class, 'index'])->name('home');
|
||||||
|
|
||||||
// Auth Routes
|
// Auth Routes
|
||||||
|
|
||||||
Route::get('/login', [AuthController::class, 'showLoginForm'])->name('login');
|
Route::get('/login', [AuthController::class, 'showLoginForm'])->name('login');
|
||||||
Route::post('/login', [AuthController::class, 'login']);
|
Route::post('/login', [AuthController::class, 'login']);
|
||||||
Route::get('/forgot-password', [AuthController::class, 'showForgetPasswordForm'])->name('forget.password');
|
Route::get('/forgot-password', [AuthController::class, 'showForgetPasswordForm'])->name('forget.password');
|
||||||
|
|
@ -29,6 +28,15 @@
|
||||||
Route::get('/news/{slug}', [NewsController::class, 'show'])->name('news.show');
|
Route::get('/news/{slug}', [NewsController::class, 'show'])->name('news.show');
|
||||||
Route::get('/api/news/categories', [NewsController::class, 'getCategories'])->name('news.categories');
|
Route::get('/api/news/categories', [NewsController::class, 'getCategories'])->name('news.categories');
|
||||||
|
|
||||||
|
Route::get('/attendance/sessions/{sessionId}', [AttendanceController::class, 'showPage'])
|
||||||
|
->name('attendance.session.show');
|
||||||
|
Route::get('/admin/attendance/sessions/{sessionId}/qrcode', [AttendanceController::class, 'currentToken'])
|
||||||
|
->name('admin.attendance.session.qrcode');
|
||||||
|
Route::get('/admin/attendance/sessions/{sessionId}/members', [AttendanceController::class, 'members'])
|
||||||
|
->name('admin.attendance.session.members');
|
||||||
|
Route::post('/admin/attendance/sessions/{sessionId}/rotate', [AttendanceController::class, 'forceRotate'])
|
||||||
|
->name('admin.attendance.session.rotate');
|
||||||
|
|
||||||
// Admin routes
|
// Admin routes
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
@ -95,12 +103,3 @@
|
||||||
|
|
||||||
Route::get('/logout', [AuthController::class, 'logout'])->name('logout');
|
Route::get('/logout', [AuthController::class, 'logout'])->name('logout');
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::get('/attendance/sessions/{sessionId}', [AttendanceController::class, 'showPage'])
|
|
||||||
->name('attendance.session.show');
|
|
||||||
Route::get('/admin/attendance/sessions/{sessionId}/qrcode', [AttendanceController::class, 'currentToken'])
|
|
||||||
->name('admin.attendance.session.qrcode');
|
|
||||||
Route::get('/admin/attendance/sessions/{sessionId}/members', [AttendanceController::class, 'members'])
|
|
||||||
->name('admin.attendance.session.members');
|
|
||||||
Route::post('/admin/attendance/sessions/{sessionId}/rotate', [AttendanceController::class, 'forceRotate'])
|
|
||||||
->name('admin.attendance.session.rotate');
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue