App\Http\Controllers\API\LastfmController::connect PHP Method

connect() public method

Connect the current user to Last.fm.
public connect ( Redirector $redirector, Lastfm $lastfm, Tymon\JWTAuth\JWTAuth $auth = null ) : Redirector | Illuminate\Http\RedirectResponse
$redirector Illuminate\Routing\Redirector
$lastfm App\services\Lastfm
$auth Tymon\JWTAuth\JWTAuth
return Illuminate\Routing\Redirector | Illuminate\Http\RedirectResponse
    public function connect(Redirector $redirector, Lastfm $lastfm, JWTAuth $auth = null)
    {
        abort_unless($lastfm->enabled(), 401, 'Koel is not configured to use with Last.fm yet.');
        $auth = $auth ?: $this->app['tymon.jwt.auth'];
        // A workaround to make sure Tymon's JWTAuth get the correct token via our custom
        // "jwt-token" query string instead of the default "token".
        // This is due to the problem that Last.fm returns the token via "token" as well.
        $auth->parseToken('', '', 'jwt-token');
        return $redirector->to('https://www.last.fm/api/auth/?api_key=' . $lastfm->getKey() . '&cb=' . urlencode(route('lastfm.callback') . '?jwt-token=' . $auth->getToken()));
    }