Get user's block list.

@param string $user  Username
@param string $token Twitch token

@return JSON List of ignored users
179592
public function blocks($user, $token = null)
    {
        return $this->sendRequest('GET', 'users/'.$user.'/blocks', $this->getToken($token));
    }
1020632
public static function get_blocked_users($userid) {
        global $CFG, $USER, $PAGE;

        // Warnings array, it can be empty at the end but is mandatory.
        $warnings = array();

        // Validate params.
        $params = array(
            'userid' => $userid
        );
        $params = self::validate_parameters(self::get_blocked_users_parameters(), $params);
        $userid = $params['userid'];

        // Validate context.
        $context = context_system::instance();
        self::validate_context($context);

        // Check if private messaging between users is allowed.
        if (empty($CFG->messaging)) {
            throw new moodle_exception('disabled', 'message');
        }

        $user = core_user::get_user($userid, '*', MUST_EXIST);
        core_user::require_active_user($user);

        // Check if we have permissions for retrieve the information.
        $capability = 'moodle/site:manageallmessaging';
        if (($USER->id != $userid) && !has_capability($capability, $context)) {
            throw new required_capability_exception($context, $capability, 'nopermissions', '');
        }

        // Now, we can get safely all the blocked users.
        $users = \core_message\api::get_blocked_users($user->id);

        $blockedusers = array();
        foreach ($users as $user) {
            $newuser = array(
                'id' => $user->id,
                'fullname' => fullname($user),
            );

            $userpicture = new user_picture($user);
            $userpicture->size = 1; // Size f1.
            $newuser['profileimageurl'] = $userpicture->get_url($PAGE)->out(false);

            $blockedusers[] = $newuser;
        }

        $results = array(
            'users' => $blockedusers,
            'warnings' => $warnings
        );
        return $results;
    }
935031
public static function get_user_info($oauth_token) {
	$url     = 'https://api.github.com/user';
	$options = [
		'headers' => [
			'Accept' => 'application/json',
			'Authorization' => 'token '.$oauth_token,
		],
	];
	
	$http = new \GuzzleHttp\Client();
	return $http->get($url, $options)->json();
}
432049
public function videosFollowed($token = null)
    {
        $token = $this->getToken($token);

        $usersAPI = new Users($token);

        return $usersAPI->videosFollowed();
    }
263753
private function verifyPersistToken($username, $token)
	{
		$this->debug->groupCollapsed(__METHOD__);
		$return = false;
		$vals = array(
			'username'		=> $this->db->quoteValue($username),
			'token_hash'	=> $this->db->quoteValue(sha1($token)),
		);
		$query = Str::quickTemp('SELECT * FROM `persist_tokens`
			LEFT JOIN `user_auth`
				ON `user_auth`.`username` = [::username::]
				AND `user_auth`.`userid` = `persist_tokens`.`userid`
			WHERE `token_hash` = [::token_hash::]
			ORDER BY `datetime` DESC', $vals);
		$rows = $this->db->query($query)[0];
		$this->debug->table($rows, 'rows');
		if ($rows) {
			// found token in table
			$return = $rows[0]['userid'];
			// remove the token
			$where = array();
			foreach (array('userid','datetime','token_hash') as $k) {
				$where[$k] = $rows[0][$k];
			}
			$this->db->rowMan('persist_tokens', null, $where);
			$this->log('persistTokenSuccess', $rows[0]['userid']);
		} else {
			$this->log('persistTokenFail');
		}
		$this->debug->groupEnd();
		return $return;
	}
886722
public function userToRooms($user)
    {
        $url          = $this->url.'users/'.$user.'/joined_chatrooms';
        $option       = [];
        $access_token = $this->getToken();
        $header []    = 'Authorization: Bearer '.$access_token;

        return Http::postCurl($url, $option, $header, 'GET');
    }
271206
protected function getImpersonatingUserFromRole($token, $user = null)
    {
        foreach ($token->getRoles() as $role) {
            if ($role instanceof SwitchUserRole) {
                $user = $role->getSource()->getUser();
                break;
            }
        }

        return $user;
    }
678683
public function getHeaders($token = null)
    {
        if ($token) {
            return array_merge(
                $this->getDefaultHeaders(),
                $this->getAuthorizationHeaders($token)
            );
        }

        return $this->getDefaultHeaders();
    }
44625
private function userBlocks(int $user_id, string $location): Collection
    {
        $rows = DB::table('block')
            ->where('user_id', '=', $user_id)
            ->where('location', '=', $location)
            ->orderBy('block_order')
            ->pluck('module_name', 'block_id');

        return $this->filterActiveBlocks($rows, $this->availableUserBlocks());
    }
667829
@Get("/tokens")
    public CompletableFuture<Collection<Token>> listTokens(User loginUser) {
        if (loginUser.isAdmin()) {
            return mds.getTokens()
                      .thenApply(tokens -> tokens.appIds().values());
        } else {
            return mds.getTokens()
                      .thenApply(Tokens::withoutSecret)
                      .thenApply(tokens -> tokens.appIds().values());
        }
    }
662645
public function channelSubscriptionsUser($channel, $user, $token = null)
    {
        $token = $this->getToken($token);
        $url = 'https://api.twitch.tv/kraken/channels/' . $channel . '/subscriptions/' . $user;

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

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

        return $response->json();
    }
1129054
protected function getUserByToken($token)
    {
        $userUrl = 'https://' . $this->shopURL . $this->adminPath . "shop.json";


        $response = $this->getHttpClient()->get( $userUrl,
                [
                    'headers' => $this->getResponseHeaders($token)
                ]);

        $user = json_decode($response->getBody(), true);

        $this->responseHeaders = $response->getHeaders();

        return $user['shop'];
    }
97144
public function findByTokenApiCode($token_api)
	{
		$model = $this->createModel();

		$result = $model->newQuery()->where('token_api', '=', $token_api)->get();

		if (($count = $result->count()) > 1)
		{
			throw new \RuntimeException("Found [$count] users with the same token api.");
		}

		if ( ! $user = $result->first())
		{
			throw new UserNotFoundException("A user was not found with the given token api.");
		}

		return $user;
	}
381954
public function actionLoginCallback($token)
    {
        /** @var \amnah\yii2\user\models\User $user */
        /** @var \amnah\yii2\user\models\Profile $profile */
        /** @var \amnah\yii2\user\models\Role $role */
        /** @var \amnah\yii2\user\models\UserToken $userToken */

        $user = $this->module->model("User");
        $profile = $this->module->model("Profile");
        $userToken = $this->module->model("UserToken");

        // check token and log user in directly
        $userToken = $userToken::findByToken($token, $userToken::TYPE_EMAIL_LOGIN);
        if ($userToken && $userToken->user) {
            $returnUrl = $this->performLogin($userToken->user, $userToken->data);
            $userToken->delete();
            return $this->redirect($returnUrl);
        }

        // load post data
        $post = Yii::$app->request->post();
        $userLoaded = $user->load($post);
        $profileLoaded = $profile->load($post);
        if ($userToken && ($userLoaded || $profileLoaded)) {

            // ensure that email is taken from the $userToken (and not from user input)
            $user->email = $userToken->data;

            // validate and register
            if ($user->validate() && $profile->validate()) {
                $role = $this->module->model("Role");
                $user->setRegisterAttributes($role::ROLE_USER, $user::STATUS_ACTIVE)->save();
                $profile->setUser($user->id)->save();

                // log user in and delete token
                $returnUrl = $this->performLogin($user);
                $userToken->delete();
                return $this->redirect($returnUrl);
            }
        }

        $user->email = $userToken ? $userToken->data : null;
        return $this->render("loginCallback", compact("user", "profile", "userToken"));
    }
52251
public function getActivate(Request $request, $token)
    {

        $user = User::where('token', $token)->first();
        if (!$user) {
            throw new NotFoundHttpException;
        }

        $user->is_activated = true;
        $user->token        = null;
        $user->save();

        if (method_exists($this, 'userActivated')) {
            $this->userRegistered($request, $token, $user);
        }

        return view($this->getUserActivatingView(), ['user' => $user, 'token' => $token]);
    }
1055231
public function userPendingItems(Member $user)
    {
        // Don't restrict anything for ADMIN users
        $userInstances = DataList::create(WorkflowInstance::class)
            ->where('"WorkflowStatus" != \'Complete\'')
            ->sort('LastEdited DESC');

        if (Permission::checkMember($user, 'ADMIN')) {
            return $userInstances;
        }
        $instances = new ArrayList();
        foreach ($userInstances as $inst) {
            $instToArray = $inst->getAssignedMembers();
            if (!count($instToArray)>0 || !in_array($user->ID, $instToArray->column())) {
                continue;
            }
            $instances->push($inst);
        }

        return $instances;
    }
341121
public function putBlock($user, $target, $token = null)
    {
        $token = $this->getToken($token);

        $blocksApi = new Blocks($token);

        return $blocksApi->putBlock($user, $target);
    }