статический конструктор
@param AbstractUser $user
@param bool $remember
@return UserAccessTokenInterface
@throws Exception
@throws \Throwable
197601
public static function create(AbstractUser $user, bool $remember = false): UserAccessTokenInterface
    {
        $token = self::find()->where(['user_id' => $user->id, 'is_active' => 1])->orderBy(['created_at' => SORT_DESC])->one();
        if ($token instanceof UserAccessTokenInterface && $token->expired_at > time()) {
            return $token;
        }
        $user->deactivateTokens();
        $new_token = new static([
            'user_id' => $user->id,
            'access_token' => self::generateToken($user->email),
            'expired_at' => self::generateExpired($remember),
            'is_active' => 1,
        ]);
        (new UserAccessTokenHandler($new_token))->create();
        $new_token->refresh();
        $user->updateLastEntering();
        return $new_token;
    }
1044926
protected function setUserInformation(UserInterface $user, UserResponseInterface $userInformation)
    {
        $accessor = PropertyAccess::createPropertyAccessor();
        $accessor->setValue($user, 'username', $this->getUniqueUserName($userInformation->getNickname()));

        if (method_exists($accessor, 'isWritable') && $accessor->isWritable($user, 'email')) {
            $accessor->setValue($user, 'email', $userInformation->getEmail());
        } elseif (method_exists($user, 'setEmail')) {
            $user->setEmail($userInformation->getEmail());
        }

        return $user;
    }
177217
protected function queueRecallerCookie(AuthenticatableContract $user)
    {
        $this->getCookieJar()->queue($this->createRecaller(
            $user->getAuthIdentifier().'|'.$user->getRememberToken().'|'.$user->getAuthPassword()
        ));
    }
826932
public function create(RemindableInterface $user)
	{
		$email = $user->getReminderEmail();

		// We will create a new, random token for the user so that we can e-mail them
		// a safe link to the password reset form. Then we will insert a record in
		// the database so that we can verify the token within the actual reset.
		$token = $this->createNewToken($user);

		$this->getTable()->insert($this->getPayload($email, $token));

		return $token;
	}
264005
public function forgotPassword( $user ) {

		$modelClass	= static::$modelClass;

		// Find existing user
		$userToUpdate = $modelClass::findById( $user->id );

		// Generate Token
		$userToUpdate->generateResetToken();
		$userToUpdate->generateOtp();

		// Update User
		$userToUpdate->update();

		return $userToUpdate;
	}
718312
public function login(UserInterface $user, $remember = false)
    {
        $this->updateSession($user->getAuthIdentifier());

        // If the user should be permanently "remembered" by the application we will
        // queue a permanent cookie that contains the encrypted copy of the user
        // identifier. We will then decrypt this later to retrieve the users.
        if ($remember) {
            $this->createRememberTokenIfDoesntExist($user);

            $this->queueRecallerCookie($user);
        }

        // If we have an event dispatcher instance set we will fire an event so that
        // any listeners will hook into the authentication events and run actions
        // based on the login and logout events fired from the guard instances.
        if (isset($this->events)) {
            $this->events->dispatch('auth.login', array($user, $remember));
        }

        $this->setUser($user);
    }
836032
public function loginUsingId($id, $remember = false)
    {
        if (! is_null($user = $this->provider->retrieveById($id))) {
            $this->login($user, $remember);

            return $user;
        }

        return false;
    }
197529
public function updateRememberToken(UserContract $user, $token)
    {
        $user->setRememberToken($token);

        $timestamps = $user->timestamps;

        $user->timestamps = false;

        $user->save();

        $user->timestamps = $timestamps;
    }
516314
protected function fireLoginEvent($user, $remember = FALSE)
    {
        if (isset($this->events)) {
            $this->events->dispatch(new Login($user, $remember));
        }
    }
128580
public function login(UserContract $user, $remember = false)
    {
        wp_set_auth_cookie($user->ID, $remember);

        wp_set_current_user($user->ID);

        // If we have an event dispatcher instance set we will fire an event so that
        // any listeners will hook into the authentication events and run actions
        // based on the login and logout events fired from the guard instances.
        $this->fireLoginEvent($user, $remember);

        $this->setUser($user);
    }
1314473
private function userAttemptBruteForceLockHasExceeded(User $user)
    {
        if ($user->login_attempt_lock_expiration > time()) {
            $user->updateAttributes(['login_attempt' => 0]);
            
            return true;
        }
        
        return false;
    }
167210
protected function performLogin($user, $rememberMe = true)
    {
        // log user in
        $loginDuration = $rememberMe ? $this->module->loginDuration : 0;
        Yii::$app->user->login($user, $loginDuration);

        // check for a valid returnUrl (to prevent a weird login bug)
        //   https://github.com/amnah/yii2-user/issues/115
        $loginRedirect = $this->module->loginRedirect;
        $returnUrl = Yii::$app->user->getReturnUrl($loginRedirect);
        if (strpos($returnUrl, "user/login") !== false || strpos($returnUrl, "user/logout") !== false) {
            $returnUrl = null;
        }

        return $returnUrl;
    }
632882
public function setToken(UserSession $user, Token $token)
    {
        $item = $this->cacheItemPool->getItem($this->cacheKey($user));
        $item->set($token);
        // @todo Test that these values are compatible.
        $item->expiresAfter($token->getLifetime());
        $this->cacheItemPool->save($item);
    }
1349930
protected function expireRefreshToken($refreshToken, $user)
    {
        $token = $this->refreshTokenMapper->findBy([
            'refresh_token' => $refreshToken,
            'user_id'       => $user->getId(),
        ]);

        if (! $token) {
            throw new OutOfBoundsException('Refresh token not found.');
        }

        $token->setExpires(date("Y-m-d H:i:s", time()));

        $this->refreshTokenMapper->update($token);
    }
213057
public function verifyTwoFactor(UserInterface $user, $token, $remember = false)
    {
        $this->getTwoFactorStrategy()->verify($user, $token);

        // mark the user as 2FA verified, now and for the session
        $user->markTwoFactorVerified();

        // the user is now considered fully signed in
        // now we want to perform the sign in so an event is recorded
        // and a remember me token is generated, if needed
        if (!$user->isSignedIn()) {
            $this->signInUser($user, '2fa', $remember);
        }

        $saved = $this->getStorage()
                      ->twoFactorVerified($user,
                                          $this->request,
                                          $this->response);
        if (!$saved) {
            throw new AuthException('Unable to mark user session as two-factor verified');
        }

        return $this;
    }
1248313
public function login( Account $acct, $remember = false )
	{
		$this->updateSession( $acct->getId() );

		// If the acct should be permanently "remembered" by the application we will
		// queue a permanent cookie that contains the encrypted copy of the acct
		// identifier. We will then decrypt this later to retrieve the accts.
		if ( $remember )
		{
			$this->createRememberTokenIfDoesntExist( $acct );

			$this->queueRecallerCookie( $acct );
		}

		// If we have an event dispatcher instance set we will fire an event so that
		// any listeners will hook into the authentication events and run actions
		// based on the login and logout events fired from the guard instances.
		$this->fireLoginEvent( $acct, $remember );

		$this->setAcct( $acct );
	}
1245226
public function deleteUser(User $user)
    {

        /* When the api will identify a user, please uncomment this
        if ($this->container->get('security.token_storage')->getToken()->getUser()->getId() === $user->getId()) {
            throw new \Exception('A user cannot delete himself');
        }*/
        $userRole = $this->roleManager->getUserRoleByUser($user);

        //soft delete~
        $user->setMail('mail#' . $user->getId());
        $user->setFirstName('firstname#' . $user->getId());
        $user->setLastName('lastname#' . $user->getId());
        $user->setPlainPassword(uniqid());
        $user->setUsername('username#' . $user->getId());
        $user->setPublicUrl('removed#' . $user->getId());
        $user->setAdministrativeCode('code#' . $user->getId());
        $user->setIsEnabled(false);

        // keeping the user's workspace with its original code
        // would prevent creating a user with the same username
        // todo: workspace deletion should be an option
        $ws = $user->getPersonalWorkspace();

        if ($ws) {
            $ws->setCode($ws->getCode() . '#deleted_user#' . $user->getId());
            $ws->setDisplayable(false);
            $this->objectManager->persist($ws);
        }

        if ($userRole) {
            $this->objectManager->remove($userRole);
        }
        $this->objectManager->persist($user);
        $this->objectManager->flush();

        $this->strictEventDispatcher->dispatch('claroline_users_delete', 'GenericDatas', array(array($user)));
        $this->strictEventDispatcher->dispatch('log', 'Log\LogUserDelete', array($user));
        $this->strictEventDispatcher->dispatch('delete_user', 'DeleteUser', array($user));
    }