mirror of
https://github.com/koel/koel
synced 2024-12-13 14:12:27 +00:00
37 lines
934 B
PHP
37 lines
934 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 $lastfm;
|
|
|
|
/** @var User */
|
|
private $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);
|
|
}
|
|
}
|