koel/app/Http/Controllers/API/LastfmController.php
2021-06-05 12:47:56 +02:00

37 lines
965 B
PHP

<?php
namespace App\Http\Controllers\API;
use App\Http\Requests\API\LastfmSetSessionKeyRequest;
use App\Models\User;
use App\Services\LastfmService;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Http\Response;
class LastfmController extends Controller
{
private LastfmService $lastfm;
/** @var User */
private ?Authenticatable $currentUser;
public function __construct(LastfmService $lastfm, ?Authenticatable $currentUser)
{
$this->lastfm = $lastfm;
$this->currentUser = $currentUser;
}
public function setSessionKey(LastfmSetSessionKeyRequest $request)
{
$this->lastfm->setUserSessionKey($this->currentUser, trim($request->key));
return response()->json(null, Response::HTTP_NO_CONTENT);
}
public function disconnect()
{
$this->lastfm->setUserSessionKey($this->currentUser, null);
return response()->json(null, Response::HTTP_NO_CONTENT);
}
}