mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-14 15:37:53 +00:00
fix(#158): do not require ID header on /display endpoint
Some checks are pending
tests / ci (push) Waiting to run
Some checks are pending
tests / ci (push) Waiting to run
This commit is contained in:
parent
c2c553461f
commit
d7f6237265
2 changed files with 4 additions and 6 deletions
|
|
@ -18,15 +18,13 @@ use Illuminate\Support\Str;
|
|||
Route::get('/display', function (Request $request) {
|
||||
$mac_address = $request->header('id');
|
||||
$access_token = $request->header('access-token');
|
||||
$device = Device::where('mac_address', mb_strtoupper($mac_address ?? ''))
|
||||
->where('api_key', $access_token)
|
||||
->first();
|
||||
$device = Device::where('api_key', $access_token)->first();
|
||||
|
||||
if (! $device) {
|
||||
// Check if there's a user with assign_new_devices enabled
|
||||
$auto_assign_user = User::where('assign_new_devices', true)->first();
|
||||
|
||||
if ($auto_assign_user) {
|
||||
if ($auto_assign_user && $mac_address) {
|
||||
// Create a new device and assign it to this user
|
||||
$device = Device::create([
|
||||
'mac_address' => mb_strtoupper($mac_address ?? ''),
|
||||
|
|
@ -39,7 +37,7 @@ Route::get('/display', function (Request $request) {
|
|||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'message' => 'MAC Address not registered or invalid access token',
|
||||
'message' => 'MAC Address not registered (or not set), or invalid access token',
|
||||
], 404);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue