2015-12-20 12:17:35 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\API;
|
|
|
|
|
2017-12-09 18:34:27 +00:00
|
|
|
use App\Http\Requests\API\LastfmSetSessionKeyRequest;
|
2020-09-06 18:21:39 +00:00
|
|
|
use App\Models\User;
|
|
|
|
use Illuminate\Contracts\Auth\Authenticatable;
|
2020-09-13 22:04:07 +00:00
|
|
|
use Illuminate\Http\Response;
|
2015-12-20 12:17:35 +00:00
|
|
|
|
|
|
|
class LastfmController extends Controller
|
|
|
|
{
|
2020-09-06 18:21:39 +00:00
|
|
|
/** @var User */
|
|
|
|
private $currentUser;
|
|
|
|
|
2020-09-07 20:43:23 +00:00
|
|
|
public function __construct(?Authenticatable $currentUser)
|
2018-09-04 06:25:24 +00:00
|
|
|
{
|
2020-09-06 18:21:39 +00:00
|
|
|
$this->currentUser = $currentUser;
|
2015-12-20 12:17:35 +00:00
|
|
|
}
|
|
|
|
|
2017-12-09 18:34:27 +00:00
|
|
|
public function setSessionKey(LastfmSetSessionKeyRequest $request)
|
2016-01-26 06:32:29 +00:00
|
|
|
{
|
2020-09-06 18:21:39 +00:00
|
|
|
$this->currentUser->savePreference('lastfm_session_key', trim($request->key));
|
2016-01-26 06:32:29 +00:00
|
|
|
|
2020-09-13 22:04:07 +00:00
|
|
|
return response()->json(null, Response::HTTP_NO_CONTENT);
|
2016-01-26 06:32:29 +00:00
|
|
|
}
|
|
|
|
|
2015-12-20 12:17:35 +00:00
|
|
|
public function disconnect()
|
|
|
|
{
|
2020-09-06 18:21:39 +00:00
|
|
|
$this->currentUser->deletePreference('lastfm_session_key');
|
2018-09-04 02:25:34 +00:00
|
|
|
|
2020-09-13 22:04:07 +00:00
|
|
|
return response()->json(null, Response::HTTP_NO_CONTENT);
|
2015-12-20 12:17:35 +00:00
|
|
|
}
|
|
|
|
}
|