Register new User into the web.
Creates new token given a user, with related Role set.

@param AbstractUserInterface $user User to register

@return $this Self object
187806
public function register(AbstractUserInterface $user)
    {
        parent::register($user);

        /**
         * @var CustomerInterface $user
         */
        $this
            ->userEventDispatcher
            ->dispatchOnCustomerRegisteredEvent($user);

        return $this;
    }
579356
private function resetEmail(UserInterface $user)
    {
        $ttl = $this->container->getParameter('fos_user.resetting.token_ttl');
        if ($user->isPasswordRequestNonExpired($ttl)) {
            return self::RESET_EMAIL_ALREADY_SENT;
        }

        if (null === $user->getConfirmationToken()) {
            /**
             * @var $tokenGenerator \FOS\UserBundle\Util\TokenGeneratorInterface
             */
            $tokenGenerator = $this->container->get('fos_user.util.token_generator');
            $user->setConfirmationToken($tokenGenerator->generateToken());
        }

        $this->container->get('session')->set(
            static::SESSION_EMAIL,
            $this->getObfuscatedEmail($user)
        );
        $this->container->get('fos_user.mailer')->sendResettingEmailMessage($user);
        $user->setPasswordRequestedAt(new \DateTime());
        $this->container->get('fos_user.user_manager')->updateUser($user);

        return self::RESET_EMAIL_OK;
    }
606705
public function dispatchOnAdminUserRegisteredEvent(AdminUserInterface $adminUser)
    {
        $event = new AdminUserRegisterEvent($adminUser);
        $this
            ->eventDispatcher
            ->dispatch(
                ElcodiUserEvents::ADMINUSER_REGISTER,
                $event
            );

        return $this;
    }
928899
protected function createRememberTokenIfDoesntExist(UserInterface $user)
    {
        $rememberToken = $user->getRememberToken();

        if (empty($rememberToken)) {
            $this->refreshRememberToken($user);
        }
    }
454869
public function login(UserInterface $user, $firewallName = 'main')
    {
        $token = new UsernamePasswordToken($user, $user->getPassword(), $firewallName, $user->getRoles());
        $this->tokenStorage->setToken($token);

        return $user;
    }
1114009
public function login(UserInterface $user, $remember = false)
	{
		$this->updateSession($id = $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->queueRecallerCookie($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.
		if (isset($this->events))
		{
			$this->events->fire('auth.login', array($user, $remember));
		}

		$this->setUser($user);
	}
416279
public static function fromToken(TokenInterface $token)
    {
        $user = $token->getUser();

        if ($user instanceof UserInterface) {
            return self::fromAccount($user);
        }

        throw new InvalidArgumentException('The user class must implement "Fxp\Component\Security\Model\UserInterface"');
    }
254673
public function setUser(User $user)
    {
        $this->user = $user;
        $this->user->addTweet($this);

        return $this;
    }
253310
public function addUserSocialAccount(User $user, $serviceName, AbstractUser $response)
    {
        $user->has_social_integrations = true;
        $user->save();
        // create relation for new user and social integration
        $this->addSocialRelation($user, $serviceName, $response);
        return $user;
    }
787807
public static function login(UserInterface $user): void
    {
        Session::regenerate(false);
        Session::put('wt_user', $user->id());
    }
1225291
public function saveUserToken(AbstractUser $user)
    {
        return $this->httpCookie()->save($this->getTokenName(), $this->encryptUserData($user), $this->getTokenTtl());
    }
1178843
public function encryptUserData(AbstractUser $user)
    {
        // extract the roles
        $roles = $user->getRoles();
        $roleArray = [];
        foreach($roles as $r){
            $roleArray[] = $r->getRole();
        }

        // data (we use short syntax to reduce the size of the cookie or session)
        $data = [
            // username
            'u'   => $user->getUsername(),
            // roles
            'r'   => $roleArray,
            // valid until
            'vu'  => time() + (86400 * 30),
            // session id
            'sid' => $this->httpSession()->getSessionId(),
            // auth provider driver
            'ap'  => $user->getAuthProviderName()
        ];

        // build and add token to $data
        return $this->getCrypt()->encrypt($this->jsonEncode($data), $this->getEncryptionKey());
    }
297774
function setCurrentUser(UserInterface $user)
    {
        $this->currentUser = $user;

        // accessing the current user from the
        // DI container is deprecated
        $this->app['user'] = $user;

        return $this;
    }
153458
public function forceUserStateless(UserInterface $user)
    {
        $user = $this->sentinel->authenticate($user, false, false);

        if ( ! ($user instanceof CartalystUserInterface)) {
            return false;
        }

        event( new CmsUserLoggedIn($user, true, true) );
        return true;
    }
1290862
public function setUser(?string $user): AtlassianRestClient
    {
        $this->user = $user;
        $this->client = $this->createClient();

        return $this;
    }
746462
protected function refreshRememberToken(UserInterface $user)
    {
        $user->setRememberToken($token = str_random(60));

        $this->provider->updateRememberToken($user, $token);
    }
1069333
public static function create(UserInterface $user): UserMetaInterface
    {
        /** @var AbstractUser $user */
        $user_meta = static::findOne(['user_id' => $user->id]);
        if ($user_meta instanceof UserMetaInterface) {
            return $user_meta;
        }
        $user_meta = new static([
            'user_id' => $user->id,
            'notification_email' => $user->email,
            'display_name' => $user->username,
        ]);
        (new UserMetaHandler($user_meta))->create();
        $user_meta->refresh();
        return $user_meta;
    }