Finds registered user by activation token.
@param string $token activation token
@return static|null
432495
public static function findByActivationToken($token)
    {
        if (!static::isActivationTokenValid($token)) {
            return null;
        }
        return static::find()->where(['activation_token' => $token, 'status' => self::STATUS_REGISTERED])->limit(1)->one();
    }
981650
public function validate($token)
    {
        $autologin = $this->provider->findByToken($token);

        if ($autologin && $this->autologinValid($autologin)) {
            if (config('autologin.count')) {
                $autologin->incrementCount();
            }

            return $autologin;
        }

        return null;
    }
1026160
public static function findForAuthToken($identifier, $token) {
		return self::where(self::META_USER_PRIMARY_KEY, '=', $identifier)
			->where('remember_token', '=', $token)
			->first();
	}
225684
public function getByAccessToken(string $token)
	{
		return $this->setAuthorizer($this->getModel()->where('access_token', '=', $token)->first());
	}
1182144
public function getTransactionResult($token = null)
    {
        if (!$token) {
            $token = $_POST['token_ws'];
        }

        return $this->service->getTransactionResult($token)->return;
    }
689301
public function activate($tokenString)
    {
        $token = $this->findToken($tokenString);

        // If we could not find a token or it has expired, fail the attempt.
        if (is_null($token) || $token->isExpired()) {
            return Response::failed('Activation failed.')
                           ->route('auth.invitation.failed', $tokenString);
        }

        // Activate the user and log them in.
        $token->user->activateInvitation();

        auth()->login($token->user);

        return Response::passed('Your account has been activated.')
                       ->route('home');
    }
628092
private function findUserByValidToken($token)
    {
        try {
            /** @var UserInterface $user */
            $user = $this->getUserRepository()->findUserByToken($token);
            if (new \DateTime() > $user->getPasswordResetTokenExpiresAt()) {
                throw new InvalidTokenException($token);
            }

            return $user;
        } catch (NoResultException $exc) {
            throw new InvalidTokenException($token);
        }
    }
824123
public function getActivationLink(Token $token)
    {
        $activationConfiguration = $token->getPreset()['activation'];
        $tokenHash = $token->getHash();

        if ($activationConfiguration['uri'] === null) {
            throw new \RuntimeException('Building activation link failed, no uri configuration is set', 1434728943);
        } elseif (is_array($activationConfiguration['uri'])) {
            $routerConfiguration = $activationConfiguration['uri'];

            $this->uriBuilder->setRequest($this->request);
            $uri = $this->uriBuilder
                ->setCreateAbsoluteUri(true)
                ->setFormat($routerConfiguration['@format'])
                ->uriFor(
                    $routerConfiguration['@action'],
                    $routerConfiguration['arguments'],
                    $routerConfiguration['@controller'],
                    $routerConfiguration['@package'],
                    $routerConfiguration['@subpackage']
                );
        } elseif (is_string($activationConfiguration['uri'])) {
            $uri = $activationConfiguration['uri'];
        } else {
            throw new \RuntimeException('Building activation link failed, uri configuration is invalid (neither array nor string)', 1434732898);
        }

        $this->logger->log(sprintf('Activation link built for token with hash %s', $tokenHash, $token->getIdentifier()), LOG_INFO);

        return str_replace('-tokenhash-', $tokenHash, $uri);
    }
1373854
public function userFromToken(string $token)
    {
        $user = $this->mapUserToObject($this->getUserByToken($token));
        return $user->setToken($token);
    }
271206
protected function getImpersonatingUserFromRole($token, $user = null)
    {
        foreach ($token->getRoles() as $role) {
            if ($role instanceof SwitchUserRole) {
                $user = $role->getSource()->getUser();
                break;
            }
        }

        return $user;
    }
1212134
protected function getUserByToken($token)
    {
        \Php\Support\Helpers\Arr::arrayReplaceByTemplate($this->guzzle, ['{{%TOKEN%}}' => $token]);

        $response = $this->getHttpClient()->get($this->getDriverConfig('userInfoUrl'), $this->guzzle);

        return json_decode($response->getBody(), true);
    }
564287
public function setPasswordResetToken($token = '')
    {
        if (empty($this->passwordResetTokenAttribute) || !is_string($this->passwordResetTokenAttribute)) {
            return null;
        }
        return $this->{$this->passwordResetTokenAttribute} = $token;
    }
175361
public function exists($token)
    {
        $reset = PasswordReset::where('token', $token)->first();
        return $reset and ! $reset->isExpired();
    }
728579
public function showActivation(string $token)
    {
        $message = null;

        $tokenRecord = DB::table('hc_users_activations')->where('token', $token)->first();

        if( is_null($tokenRecord) ) {
            $message = trans('HCACL::users.activation.token_not_exists');
        } else {
            if( strtotime($tokenRecord->created_at) + 60 * 60 * 24 < time() ) {
                $message = trans('HCACL::users.activation.token_expired');
            }
        }

        return hcview('HCACL::auth.activation', ['token' => $token, 'message' => $message]);
    }
881250
public function authenticatedUser($token = null)
    {
        $token = $this->getToken($token);

        $usersAPI = new Users($token);

        return $usersAPI->authenticatedUser();
    }
425328
public static function findByPasswordResetToken($token)
    {
        $expire = Yii::$app->params['user.passwordResetTokenExpire'];
        $parts = explode('_', $token);
        $timestamp = (int) end($parts);
        if ($timestamp + $expire < time()) {
            // token expired
            return null;
        }

        return static::findOne([
            'password_reset_token' => $token,
            'status' => self::STATUS_ACTIVE,
        ]);
    }
1371286
public static function extractToken($token) {
    $extract = self::$config['jwt_extract']($token);
    if (!$extract) {
      return false;
    }
    $guid = $extract['guid'];

    $user = Nymph::getEntity(
        ['class' => '\Tilmeld\Entities\User'],
        ['&',
          'guid' => $guid
        ]
    );
    if (!$user || !$user->guid || !$user->enabled) {
      return false;
    }

    return $user;
  }