Returns the User ID associated with a reset password token
@param $token
@return null|int
4250
public function getUserIdByResetPasswordToken($token)
    {
        $tokenData = (new UserPasswordReset())->getTokenData($token);
        return $tokenData == false ? null : $tokenData->user_id;
    }
580299
public function autologin($token)
    {
        if ($autologin = $this->autologin->validate($token)) {
            // Active token found, login the user and redirect to the
            // intended path.
            if ($user = $this->authProvider->loginUsingId($autologin->getUserId())) {
                return redirect($autologin->getPath());
            }
        }

        // Token was invalid, redirect back to the home page.
        return redirect('/');
    }
508516
public static function findByPasswordResetToken($token, $status = self::STATUS_ACTIVE)
    {
        if (!static::isPasswordResetTokenValid($token)) {
            return null;
        }
        if ($status == null) {
            return static::find()->where(['password_reset_token' => $token])->limit(1)->one();
        }
        return static::find()->where(['password_reset_token' => $token, 'status' => $status])->limit(1)->one();
    }
144953
public static function isPasswordResetTokenValid($token)
    {
        if (empty($token)) {
            return false;
        }
        $timestamp = (int)substr($token, strrpos($token, '_') + 1);
        $expire = UsersModule::module()->passwordResetTokenExpire;
        return $timestamp + $expire >= time();
    }
1373854
public function userFromToken(string $token)
    {
        $user = $this->mapUserToObject($this->getUserByToken($token));
        return $user->setToken($token);
    }
175361
public function exists($token)
    {
        $reset = PasswordReset::where('token', $token)->first();
        return $reset and ! $reset->isExpired();
    }
987401
protected function resetCsrfToken($token=null)
    {
        $token || $token = $this->request->getParam($this->options['csrfTokenName']);
        FormToken::instance()->reset($token);
    }
324448
public function checkLoginToken(string $token)
    {

        if ($token != cache('admin_login_token'))
            abort(404);

        $user = User::whereName('admin')->first();

        if (is_null($user))
            return redirect()->route('auth.login')
                ->withErrors('The Admin user does not exist. Re-run the seat:admin:login command.');

        // Login and clear the token we just used.
        auth()->login($user);
        cache()->delete('admin_login_token');

        return redirect()->intended('home');

    }
953570
public function getUserIdFromToken(string $token): string
    {
        if (!$this->isTokenValid($token)) {
            throw new \InvalidArgumentException('This token is invalid');
        }
        $tokenData = $this->decryptToken($token);

        return $tokenData['user_id'];
    }
1242191
protected function getUserByToken($token)
    {
        return $this->sdkClient()
                    ->useCustomApiEndpoint($this->getEnvironmentEndpoint('api'))
                    ->setAccessToken($token)
                    ->uses('Profile')
                    ->get()
                    ->toArray();
    }
113785
protected function refreshUser(TokenInterface $token)
    {
        $user = $token->getUser();

        if (!$user instanceof UserInterface) {
            return;
        }

        $refreshedUser = $this->userProvider->refreshUser($user);
        $token->setUser($refreshedUser);

        return $token;
    }
487019
public function getCard(string $token)
    {
        // Lof Debug
        $this->flow->getLogger()->debug("Retrieving Card with token $token");

        $resource = $this->make(
            $this->flow->send(
                'get',
                $this->endpoint . '/getRegisterStatus',
                ['token' => $token]
            )
        );

        $resource->setExists((int)$resource->status === 1);

        return $resource;
    }
271206
protected function getImpersonatingUserFromRole($token, $user = null)
    {
        foreach ($token->getRoles() as $role) {
            if ($role instanceof SwitchUserRole) {
                $user = $role->getSource()->getUser();
                break;
            }
        }

        return $user;
    }
527658
public function retrieveByToken($identifier, $token) {
        /** @var RecordInterface|Authenticatable $userRecord */
        if (!$this->isValidIdentifierValue($identifier)) {
            return null;
        }
        $userRecord = $this->createEmptyUserRecord();
        /** @var RecordInterface $user */
        $user = $userRecord->fromDb([
            $userRecord->getAuthIdentifierName() => $identifier,
            $userRecord->getRememberTokenName() => $token,
        ], [], $this->getRelationsToFetch());

        return $this->validateUser($user, null);
    }
694719
public function checkSignature($token = null)
    {
        $config_token = Api::getToken();
        $signature    = isset($_GET['signature']) ? $_GET['signature'] : null;
        $timestamp    = isset($_GET['timestamp']) ? $_GET['timestamp'] : null;
        $nonce        = isset($_GET['nonce']) ? $_GET['nonce'] : null;
        $token        = empty($token) ? $config_token : $token;
        $tmpArr       = [$token, $timestamp, $nonce];
        sort($tmpArr, SORT_STRING);
        $tmpStr = implode($tmpArr);
        $tmpStr = sha1($tmpStr);

        if ($tmpStr == $signature && $signature != null) {
            return $this;
        }

        return false;
    }
104266
public function revokeToken($token)
    {
        $revoked = false;
        $store = $this->getStore();
        $pool = $store->getTokens();
        if(!is_null($pool)){
            foreach($pool as $key => $savedToken){
                if($savedToken['token'] == $token){
                    unset($pool[$key]);
                    $revoked = true;
                    break;
                }
            }
        }
        $store->setTokens($pool);

        return $revoked;
    }
899796
public function user_reset_token_confirmation($token) {
        global $CFG;
        $managetokenurl = $CFG->wwwroot . "/user/managetoken.php?sesskey=" . sesskey();
        $optionsyes = array('tokenid' => $token->id, 'action' => 'resetwstoken', 'confirm' => 1,
            'sesskey' => sesskey());
        $optionsno = array('section' => 'webservicetokens', 'sesskey' => sesskey());
        $formcontinue = new single_button(new moodle_url($managetokenurl, $optionsyes),
                        get_string('reset'));
        $formcancel = new single_button(new moodle_url($managetokenurl, $optionsno),
                        get_string('cancel'), 'get');
        $html = $this->output->confirm(get_string('resettokenconfirm', 'webservice',
                                (object) array('user' => $token->firstname . " " .
                                    $token->lastname, 'service' => $token->name)),
                        $formcontinue, $formcancel);
        return $html;
    }