Authenticate user

@param mixed $token
@return void
778185
public static function login($token)
  {
    $rememberMe = Remember::$rememberMe;
    $rememberMe->setCleanExpiredTokensOnLogin(true);

    $_SESSION['_uas'] = $token;

    $rememberMe->createCookie($token);

    return (object)array('status' => 'success');
  }
194686
public static function check( $token )
    {
        $token_name = 'token';

        if(Session::exists($token_name) && $token == Session::exists($token_name) )
        {
            Session::delete($token_name);
            return true;
        }
        return false;
    }
716251
public function setBearerToken(string $token): Client
    {
        $this->authenticate($token, null, self::AUTH_BEARER);

        return $this;
    }
531282
public function toUser($token = false)
    {
        $payload = $this->getPayload($token);

        if (! $user = $this->user->getBy($this->identifier, $payload['sub'])) {
            return false;
        }

        return $user;
    }
506182
public function authenticate($token = false)
    {
        $id = $this->getPayload($token)->get('sub');
        if (! $this->auth->byId($id)) {
            return false;
        }

        return $this->auth->user();
    }
1202003
public function setToken($token)
    {
        $this->token = $token;
        $this->username = '';
        $this->password = '';
        $this->accessToken = '';
        return $this;
    }
605417
public function login($token)
    {
        $subject           = SecurityUtils::getSecurityManager()->login($this, $token);
        $this->_principal  = $subject->getPrincipal();
        $this->_principals = $subject->getPrincipals();
        $this->principals = $subject->getPrincipals();

        if ($this->_principals === null || empty($this->_principals)) {
            $msg = "Principals returned from SecurityManager->login( token ) returned an empty set.".
                    "This must be populated with one or more elements.";
            throw new \Exception(msg);
        }
        $this->_authenticated = true;

    }
1052728
public function setToken($token)
    {
        $this->tokenKey = $token->key;
        $this->tokenSecret = $token->secret;

        return $this;
    }
562642
public function setAccessToken($token)
    {
        if (!$this->oauthResponse instanceof InstagramOAuth) {
            $this->oauthResponse = new InstagramOAuth(json_decode(json_encode(['access_token' => $token])));
        }
    }
684140
public function setRawToken($token)
    {
        if (\is_array($token)) {
            if (isset($token['access_token'])) {
                $this->accessToken = $token['access_token'];
            } elseif (isset($token['oauth_token'])) {
                $this->accessToken = $token['oauth_token'];
            } else {
                throw new \InvalidArgumentException('Access token was not found.');
            }

            if (isset($token['refresh_token'])) {
                $this->refreshToken = $token['refresh_token'];
            }

            if (isset($token['expires_in'])) {
                $this->setExpiresIn($token['expires_in']);
            } elseif (isset($token['oauth_expires_in'])) {
                $this->setExpiresIn($token['oauth_expires_in']);
            } elseif (isset($token['expires'])) {
                // Facebook unfortunately breaks the spec by using 'expires' instead of 'expires_in'
                $this->setExpiresIn($token['expires']);
            }

            if (isset($token['oauth_token_secret'])) {
                $this->tokenSecret = $token['oauth_token_secret'];
            }

            $this->rawToken = $token;
        } else {
            $this->accessToken = $token;
            $this->rawToken = ['access_token' => $token];
        }
    }
896083
public function authenticate(string $password): void
    {
        $salt     = random_bytes(10);
        $keyBasis = $password.$salt;
        $key      = hash(Protocol::PASSWORD_HASH_TYPE, $keyBasis, true);
        $keyHash  = hash(Protocol::PASSWORD_HASH_TYPE, $key);
        $this->setHeader($this->getHeader()." ".strtoupper(Protocol::PASSWORD_HASH_TYPE.":$keyHash.".bin2hex($salt)));

    }
139846
private function deleteToken($token)
    {
        $obj = $this->modelFactory()->create(LostPasswordToken::class);
        $obj->setToken($token);
        $obj->delete();
    }
183398
public function validateRandomSessionToken(string $token): bool
    {
        if (!isset($this->session[$this->name])) {
            return false;
        }

        return $token == $this->session[$this->name];
    }
1126704
public function authenticate($token, $authMethod = null)
    {
        if ($token === null) {
            throw InvalidArgumentException('You need to specify a token');
        }

        if ($authMethod === null) {
            $authMethod = self::AUTH_URL_TOKEN;
        }

        $this->getHttpClient()->authenticate($token, $authMethod);
    }
964063
public function loginViaToken($token)
    {
        $user = $this->userDao->getUserByToken($token);
        if ($user) {
            $this->loginWithoutPassword($user->getLogin());
            return true;
        } else {
            return false;
        }
    }
174378
protected function valid($token)
    {
        try {
            (new HttpClient)->get(
                $this->sparkUrl.'/api/token/'.$token.'/validate',
                ['verify' => __DIR__.'/cacert.pem']
            );

            return true;
        } catch (Exception $e) {
            var_dump($e->getMessage());

            return false;
        }
    }
1184848
public function activateUser(string $token)
	{
		$user = $this->userRepository->getByActionToken($token);

		if($user === false)
		{
			return false;
		}

		$user->activate();

		$user->generateActionToken();

		$user->save();

		return $user;
	}