Fire the login event if the dispatcher is set.

@param  \Illuminate\Contracts\Auth\Authenticatable $user
@param  bool                                       $remember

@return void
516314
protected function fireLoginEvent($user, $remember = FALSE)
    {
        if (isset($this->events)) {
            $this->events->dispatch(new Login($user, $remember));
        }
    }
822652
public function loginUsingId($id, $remember = false)
    {
        $this->session->put($this->getName(), $id);

        $user = $this->provider->retrieveById($id);

        $this->login($user, $remember);

        return $user;
    }
173832
public function logIn(Member $member, $persistent = false, HTTPRequest $request = null)
    {
        $member->beforeMemberLoggedIn();

        foreach ($this->getHandlers() as $handler) {
            $handler->logIn($member, $persistent, $request);
        }

        Security::setCurrentUser($member);
        $member->afterMemberLoggedIn();
    }
524897
public function attempt(array $credentials = array(), $remember = false, $login = true)
	{
		$this->fireAttemptEvent($credentials, $remember, $login);

		$this->lastAttempted = $user = $this->provider->retrieveByCredentials($credentials);

		// If an implementation of UserInterface was returned, we'll ask the provider
		// to validate the user against the given credentials, and if they are in
		// fact valid we'll log the users into the application and return true.
		if ($this->hasValidCredentials($user, $credentials))
		{
			if ($login) $this->login($user, $remember);

			return true;
		}

		return false;
	}
81347
public function logUser(User $user)
    {
        // TODO : log in an EventListener on user log event instead
        $this->strictEventDispatcher->dispatch('log', 'Log\LogUserLogin', [$user]);

        // TODO : nope, we should let Symfony handles token creation
        $token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
        $this->tokenStorage->setToken($token);

        if (null === $user->getInitDate()) {
            $this->setUserInitDate($user);
        }
        $user->setLastLogin(new \DateTime());

        $this->objectManager->persist($user);
        $this->objectManager->flush();
    }
366854
protected function fireOtherDeviceLogoutEvent($user)
    {
        if (isset($this->events)) {
            $this->events->dispatch(new Events\OtherDeviceLogout(
                $this->name, $user
            ));
        }
    }
132304
protected function createRememberTokenIfDoesntExist(UserContract $user)
    {
        $rememberToken = $user->getRememberToken();

        if (empty($rememberToken)) {
            $this->refreshRememberToken($user);
        }
    }
941309
protected function fireAttemptEvent(array $credentials, $remember, $login)
    {
        if ($this->events) {
            $payload = array($credentials, $remember, $login);

            $this->events->dispatch('auth.attempt', $payload);
        }
    }
1161609
public function login($credentials = array(), $remember = false, $secure = false)
	{
		$creds = array();

		$creds[$this->getLoginField()] = $this->getLoginCredential($credentials);

		$creds[$this->getPasswordField()] = $this->getPasswordCredential($credentials);

		$creds['remember'] = $remember;

		$user = wp_signon($creds, $secure);

		/**
		 * throw exception encapsulation of WP_Error
		 */
		if (is_wp_error($user))
		{
			throw new LoginFailedException($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->fire('auth.login', array($user, $remember));
		}

		$this->setUser($user);

		return true;
	}
381481
public function setUser(AuthenticatableContract $user)
    {
        $this->user = $user;

        $this->loggedOut = false;

        $this->fireAuthenticatedEvent($user);

        return $this;
    }
697969
protected function fireCompletedEvent(Authenticatable $user)
    {
        if ($this->completedEvent === null || !class_exists($this->completedEvent)) {
            return;
        }

        event(new $this->completedEvent($user));
    }
1148787
public function handle(Guard $auth, Dispatcher $event, Translator $translator)
    {
        if ($auth->guest()) {
            throw new SessionHasExpired($translator->get('authentication::session.expired'));
        }

        $user = $auth->user();

        $auth->logout();

        $event->fire(new UserHasLoggedOut($user));
    }
1295118
private static function setLoginSession(array $authConfig, $user)
    {
        $key = static::getFields($authConfig, true);
        $encrypted = encrypt($user->$key);
        session()->set('log_me_in', $encrypted);
    }
771261
public function login(User $user, $password)
    {
        if ($user->isPasswordValid($password)) {
            $token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
            $this->tokenStorage->setToken($token);
            $user->setLastLogin(new \DateTime());
            $this->save($user);

            return true;
        }

        return false;
    }
482286
public function loginAs(int $user_id, bool $remember = false): bool
    {
        if (!$user_id) {
            return false; // Impossible.
        }
        $on_set_auth_cookie = function (string $value) {
            $_COOKIE[is_ssl() ? SECURE_AUTH_COOKIE : AUTH_COOKIE] = $value;
        };
        $on_set_logged_in_cookie = function (string $value) {
            $_COOKIE[LOGGED_IN_COOKIE] = $value;
        };
        add_action('set_auth_cookie', $on_set_auth_cookie);
        add_action('set_logged_in_cookie', $on_set_logged_in_cookie);

        wp_clear_auth_cookie();
        wp_set_auth_cookie($user_id, $remember);

        remove_action('set_auth_cookie', $on_set_auth_cookie);
        remove_action('set_logged_in_cookie', $on_set_logged_in_cookie);

        wp_set_current_user(0);
        wp_set_current_user($user_id);

        return (int) get_current_user_id() === $user_id;
    }
916634
public function login(UserContract $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.
		$this->fireLoginEvent($user, $remember);

		$this->setUser($user);
	}
334219
protected function fireAuthenticatedEvent($user)
    {
        if (isset($this->events)) {
            $this->events->dispatch(new Authenticated($user));
        }
    }