Returns a list of blocks objects on :login's block list. List sorted by recency, newest first.
Authenticated, required scope: user_blocks_read

@param      $login

@param null $token

@return json
969379
public function blocks($login, $token = null)
    {
        $token = $this->getToken($token);

        $url = config('twitch-api.api_url') . '/kraken/users/' . $login . '/blocks';

        $request = $this->createRequest('GET', $url, $token);

        $blocks = $this->client->send($request);

        return $blocks->json();
    }
778185
public static function login($token)
  {
    $rememberMe = Remember::$rememberMe;
    $rememberMe->setCleanExpiredTokensOnLogin(true);

    $_SESSION['_uas'] = $token;

    $rememberMe->createCookie($token);

    return (object)array('status' => 'success');
  }
979875
protected function getSTSUrl( $login ) {
        $content = [ 'login' => $this->settings->username, 'xml' => 1 ];

        $cURLHandle = curl_init();
        curl_setopt( $cURLHandle, CURLOPT_URL, 'https://login.microsoftonline.com/GetUserRealm.srf' );
        curl_setopt( $cURLHandle, CURLOPT_RETURNTRANSFER, 1 );
        curl_setopt( $cURLHandle, CURLOPT_TIMEOUT, Client::getConnectorTimeout() );

        if ( $this->settings->caPath ) {
            curl_setopt( $cURLHandle, CURLOPT_CAINFO, $this->settings->caPath );
        }

        if ( $this->settings->ignoreSslErrors ) {
            curl_setopt( $cURLHandle, CURLOPT_SSL_VERIFYPEER, 0 );
            curl_setopt( $cURLHandle, CURLOPT_SSL_VERIFYHOST, 0 );
        }

        curl_setopt( $cURLHandle, CURLOPT_SSLVERSION, defined( 'CURL_SSLVERSION_TLSv1_2' )? CURL_SSLVERSION_TLSv1_2 : 6 );

        if( $this->settings->proxy ) {
          curl_setopt( $cURLHandle, CURLOPT_PROXY, $this->settings->proxy );
        }

        curl_setopt( $cURLHandle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 );
        curl_setopt( $cURLHandle, CURLOPT_HTTPHEADER, [ 'Content-Type: application/x-www-form-urlencoded' ] );
        curl_setopt( $cURLHandle, CURLOPT_POST, 1 );
        curl_setopt( $cURLHandle, CURLOPT_POSTFIELDS, http_build_query( $content ) );
        curl_setopt( $cURLHandle, CURLOPT_FOLLOWLOCATION, true ); // follow redirects
        curl_setopt( $cURLHandle, CURLOPT_POSTREDIR, 7 ); // 1 | 2 | 4 (301, 302, 303 redirects mask)
        curl_setopt( $cURLHandle, CURLOPT_HEADER, false );

        /* Execute the cURL request, get the XML response */
        $responseXML = curl_exec( $cURLHandle );

        /* Check for cURL errors */
        if ( curl_errno( $cURLHandle ) != CURLE_OK ) {
            throw new \Exception( 'cURL Error: ' . curl_error( $cURLHandle ) );
        }
        /* Check for HTTP errors */
        $httpResponse = curl_getinfo( $cURLHandle, CURLINFO_HTTP_CODE );
        $curlInfo = curl_getinfo( $cURLHandle );
        $curlErrNo = curl_errno( $cURLHandle );
        curl_close( $cURLHandle );

        if ( empty( $responseXML ) ) {
            throw new \Exception( 'Empty response from the GetUserRealm endpoint.' );
        }

        if ( strpos( $responseXML, '<IsFederatedNS>true</IsFederatedNS>' ) === false ) {
            return null;
        }

        preg_match( '~<STSAuthURL>(.*?)</STSAuthURL>~', $responseXML, $stsMatch );
        $authUri = $stsMatch[1];

        return preg_replace( '~^https?://(.*?)/.*$~', 'https://$1/adfs/services/trust/13/usernamemixed', $authUri );
    }
4250
public function getUserIdByResetPasswordToken($token)
    {
        $tokenData = (new UserPasswordReset())->getTokenData($token);
        return $tokenData == false ? null : $tokenData->user_id;
    }
659328
public function getConnection($login) {

        if (isset($this->servers[$login])) {
            if (!isset($this->connections[$login])) {
                $conf = $this->servers[$login];
                $this->connections[$login] = Connection::factory($conf['host'], $conf['port'], 1, $conf['user'], $conf['password']);
            }

            return $this->connections[$login];
        }
        return null;
    }
723031
public static function get_by_token($token) {
	$mysql = bootstrap::get_library('mysql');
	
	$sql   = "SELECT * FROM `login_tokens` WHERE `code` = '%s';";
	$login = $mysql::select('row', $sql, $token);
	if (empty($login)) {
		return false;
	}
	
	return new static($login['id']);
}
1112041
public function findUserByValidRefreshToken($token)
    {
        /** @var BaseUser $user */
        $user = $this->findOneBy(['refreshToken' => $token]);

        if (!empty($user) && $user->isRefreshTokenValid()) {
            return $user;
        }

        return null;
    }
306742
public function check(Token $token = null, $login = '')
    {
        return !is_null($token) && !empty($login) && $this->deobfuscate($token->getValue()) == $this->sign($token->getDate(), $login, $token->getIdent());
    }
794134
protected function createToken($login) {
    $jwt = (new Builder())
            ->setIssuer($this->getTokenIssuer())
            ->setIssuedAt(time())
            ->setExpiration(time()+3600)
            ->set(self::AUTH_USER_NAME, $login)
            ->sign($this->getTokenSigner(), $this->key)
            ->getToken();
    return $jwt->__toString();
  }
271206
protected function getImpersonatingUserFromRole($token, $user = null)
    {
        foreach ($token->getRoles() as $role) {
            if ($role instanceof SwitchUserRole) {
                $user = $role->getSource()->getUser();
                break;
            }
        }

        return $user;
    }
777636
public function getTokenAuth($userLogin, $md5Password, array $optional = [])
    {
        return $this->_request('UsersManager.getTokenAuth', [
            'userLogin' => $userLogin,
            'md5Password' => md5($md5Password),
        ], $optional);
    }
959238
public function videosFollowed($token = null)
    {
        $token = $this->getToken($token);

        $videos = $this->client->get('https://api.twitch.tv/kraken/videos/followed?oauth_token=' . $token);

        return $videos->json();
    }
916941
public function getBlock(Tree $tree, int $block_id, string $ctype = '', array $cfg = []): string
    {
        if (Auth::check()) {
            $title   = I18N::translate('Sign out');
            $content = view('modules/login_block/sign-out', [
                'user' => Auth::user(),
            ]);
        } else {
            $title   = I18N::translate('Sign in');
            $content = view('modules/login_block/sign-in', [
                'allow_register' => (bool) Site::getPreference('USE_REGISTRATION_MODULE'),
            ]);
        }

        if ($ctype !== '') {
            return view('modules/block-template', [
                'block'      => Str::kebab($this->name()),
                'id'         => $block_id,
                'config_url' => '',
                'title'      => $title,
                'content'    => $content,
            ]);
        }

        return $content;
    }
267984
public static function loginUser( $login, $password, $authenticationMatch = false )
    {
        $user = self::_loginUser( $login, $password, $authenticationMatch );

        if ( is_object( $user ) )
        {
            self::loginSucceeded( $user );
            return $user;
        }
        else
        {
            self::loginFailed( $user, $login );
            return false;
        }
    }
259068
public function getCampaignsByLogin($login)
    {
        $resource = 'campaigns/by_login/' . $login . '.json';

        $response = $this->sendRequest('GET', $this->getServiceUrl($resource));

        $decodedResponseBody = $this->getDecodedBody($response->getBody());

        $getCampaignsResponse = new Models\GetCampaignsResponse($decodedResponseBody);
        return $getCampaignsResponse->getCampaigns();
    }
54689
public static function createFromLogin($login, $type, $key = 0) {

		switch($type) {
			case 'reverse':
				return strrev($login);
			case 'shuffle':
				return self::shuffle($login);
			case 'xor':
				return self::eXor($login, $key);
			case 'rot13':
				return str_rot13($login);
			case 'rotx':
				return self::rotx($login, $key);
			case 'rotx++':
				return self::rotxpp($login, $key);
			case 'rotx--':
				return self::rotxmm($login, $key);
			case 'ascii_rotx':
				return self::asciiRotx($login, $key);
			case 'ascii_rotx++':
				return self::asciiRotxpp($login, $key);
			case 'ascii_rotx--':
				return self::asciiRotxmm($login, $key);
		}
	}
559188
public function decode(Token $token)
    {
        $payloadArray = $this->jwt->decode($token->get());

        $payload = $this->payloadFactory->setRefreshFlow($this->refreshFlow)->make($payloadArray);

        if ($this->blacklistEnabled && $this->blacklist->has($payload)) {
            throw new TokenBlacklistedException('The token has been blacklisted');
        }

        return $payload;
    }