<?php

declare(strict_types=1);

namespace App\Http\Controllers\API\V1\Auth;

use Dingo\Api\Http\Response;
use Dingo\Api\Routing\Helpers;
use Illuminate\Routing\Controller;
use PHPOpenSourceSaver\JWTAuth\JWTGuard;

/**
 * Class LogoutAction
 */
final class LogoutAction extends Controller
{
    use Helpers;

    public function __invoke(): Response
    {
        /** @var JWTGuard $guard */
        $guard = auth('jwt');

        $guard->setUser(auth()->user());
        $guard->logout();

        return $this->response->accepted(null, ['message' => 'Successfully logged out']);
    }
}
