Logs user in.
@return bool
977843
public function login()
    {
        if ($this->validate()) {
            return Podium::getInstance()->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);
        }
        return false;
    }
605184
protected function loginRememberedUser()
    {
        //  Is remember me functionality enabled?
        $oConfig = Factory::service('Config');
        $oConfig->load('auth/auth');

        if (!$oConfig->item('authEnableRememberMe')) {
            return false;
        }

        // --------------------------------------------------------------------------

        //  Get the credentials from the cookie set earlier
        $remember = get_cookie($this->sRememberCookie);

        if ($remember) {

            $remember = explode('|', $remember);
            $email    = isset($remember[0]) ? $remember[0] : null;
            $code     = isset($remember[1]) ? $remember[1] : null;

            if ($email && $code) {

                //  Look up the user so we can cross-check the codes
                $user = $this->getByEmail($email);

                if ($user && $code === $user->remember_code) {
                    //  User was validated, log them in!
                    $this->setLoginData($user->id);
                    $this->me = $user->id;
                }
            }
        }

        return true;
    }
1281654
public static function checkLogin()
	{
		// Only try to authenticate in the front end
		if (TL_MODE !== 'FE') {
			return false;
		}

		// Do not create a user instance if there is no authentication cookie
		if (! is_subclass_of('BackendUser', UserInterface::class) && ! \Input::cookie('BE_USER_AUTH')) {
			return false;
		}

		$User = FrontendHelperUser::getInstance();

		if (! $User->authenticate()) {
			return false;
		}

		if (! $User->rocksolidFrontendHelper) {
			return false;
		}

		if ($User->isAdmin) {
			return array('feModules', 'beModules', 'pages', 'articles', 'contents', 'infos', 'rstAssistant', 'tpl_editor');
		}

		$permissions = array();
		if (is_array($User->rocksolidFrontendHelperOperations)) {
			$permissions = array_merge($permissions, $User->rocksolidFrontendHelperOperations);
		}
		if ($User->hasAccess('rocksolid_theme_assistant', 'modules')) {
			$permissions[] = 'rstAssistant';
		}
		if ($User->hasAccess('tpl_editor', 'modules')) {
			$permissions[] = 'tpl_editor';
		}

		if (count($permissions)) {
			return $permissions;
		}

		return false;
	}
158855
public function login()
    {
        $this->loadModel('User.Users');
        $this->viewBuilder()->layout('login');

        if ($this->request->is('post')) {
            $loginBlocking =
                plugin('User')->settings('failed_login_attempts') &&
                plugin('User')->settings('failed_login_attempts_block_seconds');
            $continue = true;

            if ($loginBlocking) {
                Cache::config('users_login', [
                    'duration' => '+' . plugin('User')->settings('failed_login_attempts_block_seconds') . ' seconds',
                    'path' => CACHE,
                    'engine' => 'File',
                    'prefix' => 'qa_',
                    'groups' => ['acl']
                ]);

                $cacheName = 'login_failed_' . env('REMOTE_ADDR');
                $cache = Cache::read($cacheName, 'users_login');

                if ($cache && $cache['attempts'] >= plugin('User')->settings('failed_login_attempts')) {
                    $blockTime = (int)plugin('User')->settings('failed_login_attempts_block_seconds');
                    $this->Flash->warning(__d('user', 'You have reached the maximum number of login attempts. Try again in {0} minutes.', $blockTime / 60));
                    $continue = false;
                }
            }

            if ($continue) {
                $user = $this->Auth->identify();
                if ($user) {
                    $this->Auth->setUser($user);
                    if (!empty($user['id'])) {
                        try {
                            $user = $this->Users->get($user['id']);
                            if ($user) {
                                $this->Users->touch($user, 'Users.login');
                                $this->Users->save($user);
                            }
                        } catch (\Exception $e) {
                            // invalid user
                        }
                    }

                    return $this->redirect($this->Auth->redirectUrl());
                } else {
                    if ($loginBlocking && isset($cache) && isset($cacheName)) {
                        $cacheStruct = [
                            'attempts' => 0,
                            'last_attempt' => 0,
                            'ip' => '',
                            'request_log' => []
                        ];
                        $cache = array_merge($cacheStruct, $cache);
                        $cache['attempts'] += 1;
                        $cache['last_attempt'] = time();
                        $cache['ip'] = env('REMOTE_ADDR');
                        $cache['request_log'][] = [
                            'data' => $this->request->data,
                            'time' => time(),
                        ];
                        Cache::write($cacheName, $cache, 'users_login');
                    }
                    $this->Flash->danger(__d('user', 'Username or password is incorrect.'));
                }
            }
        }

        $user = $this->Users->newEntity();

        $this->title(__d('user', 'Login'));
        $this->set(compact('user'));
    }
976102
public function login()
    {
        if ($this->validate()) {
            UserLoginHistory::createAsync(['user_id' => $this->user->getId(), 'ip' => Yii::$app->request->userIP]);
            return Yii::$app->user->login($this->user, $this->rememberMe ? Yii::$app->settings->get('rememberFor', 'user') : 0);
        } else {
            return false;
        }
    }
264363
public function login()
    {
        //Tries to login with cookies, if the login with cookies is enabled
        if (getConfig('users.cookies_login')) {
            $this->loginWithCookie();
        }

        if ($this->request->is('post')) {
            $user = $this->Auth->identify();

            if ($user) {
                //Checks if the user is banned or if is disabled (the account
                //  should still be enabled)
                if ($user['banned'] || !$user['active']) {
                    if ($user['banned']) {
                        $this->Flash->error(__d('me_cms', 'Your account has been banned by an admin'));
                    } elseif (!$user['active']) {
                        $this->Flash->error(__d('me_cms', 'Your account has not been activated yet'));
                    }

                    return $this->buildLogout();
                }

                $this->Auth->setUser($user);

                $this->LoginRecorder->setConfig('user', $user['id'])->write();

                //Saves the login data as cookies, if requested
                if ($this->request->getData('remember_me')) {
                    $cookie = new Cookie('login', [
                        'username' => $this->request->getData('username'),
                        'password' => $this->request->getData('password'),
                    ], new DateTime('+1 year'));
                    $this->response = $this->response->withCookie($cookie);
                }

                return $this->redirect($this->Auth->redirectUrl());
            }

            if ($this->request->getData('username') && $this->request->getData('password')) {
                Log::error(sprintf(
                    '%s - Failed login with username `%s` and password `%s`',
                    $this->request->clientIp(),
                    $this->request->getData('username'),
                    $this->request->getData('password')
                ), 'users');
            }

            $this->Flash->error(__d('me_cms', 'Invalid username or password'));
        }

        $this->viewBuilder()->setLayout('login');
    }
278759
public function login()
    {
        $this->authSessionId = $this->requestAuthSessionID($this->user,
            $this->password);
        return $this->lastResponseCode == 200;
    }
236845
public function logSuccess()
    {
        /** @var XM\SecurityBundle\Entity\User $user */
        $user = $this->tokenStorage->getToken()->getUser();

        if ($user instanceof \XM\SecurityBundle\Entity\User) {
            $user->incrementLoginCount();

            $this->userManager->updateUser($user);

            $this->addLogSuccess($user);
        }
    }
1244343
public function login()
    {
        $this->loadModel('CakeManager.Roles');

        // Redirect if user is already logged in
        if ($this->authUser) {
            $redirect = $this->Roles->redirectFrom($this->authUser['role_id']);
            return $this->redirect($redirect);
        }

        if ($this->request->is('post')) {
            $user = $this->Auth->identify();
            if ($user) {
                $this->Auth->setUser($user);

                $redirect = $this->Roles->redirectFrom($user['role_id']);

                // firing an event: afterLogin
                $_event = new Event('Controller.Users.afterLogin', $this, [
                    'user' => $user
                ]);
                $this->eventManager()->dispatch($_event);

                return $this->redirect($redirect);
            }

            // firing an event: afterInvalidLogin
            $_event = new Event('Controller.Users.afterInvalidLogin', $this, [
                'user' => $user
            ]);
            $this->eventManager()->dispatch($_event);

            $this->Flash->error(__('Your username or password is incorrect.'));
        }

        $this->set('registerEnabled', Configure::read('CM.Register'));

        $this->render(Configure::read('CM.UserViews.login'));
    }
910133
public function validLoggedInAdmin()
    {
        $loggedInUser = $this->getCurrentLoggedInUser();
        if ($loggedInUser
            && $loggedInUser->administrator
            && $loggedInUser->deleted === null
            && $loggedInUser->enabled) {
                return true;
        }
        return false;
    }
721719
private function loggenIn()
    {
        if (!$this->has()) {
            if (!($this->authService instanceof UserAuthServiceInterface)) {
                // Not logged in
                return false;
            }

            // Now try to find only in cookies, if found prepare a bag
            if ($this->reAuth->isStored() && (!$this->has())) {
                $userBag = $this->reAuth->getUserBag();
            }

            // If session namespace is filled up and at the same time data stored in cookies
            if (($this->has() && $this->reAuth->isStored()) || $this->has()) {
                $data = $this->sessionBag->get(self::AUTH_NAMESPACE);

                $userBag = new UserBag();
                $userBag->setLogin($data['login'])
                        ->setPasswordHash($data['passwordHash']);
            }

            // If $userBag wasn't created so far, that means user isn't logged at all
            if (!isset($userBag)) {
                return false;
            }

            // Now let's invoke our defined match visitor
            $authResult = $this->authService->authenticate($userBag->getLogin(), $userBag->getPasswordHash(), false, false);

            if ($authResult == true) {
                // Remember success, in order not to query on each request
                $this->login($userBag->getLogin(), $userBag->getPasswordHash());
                return true;
            }

            return false;

        } else {
            return true;
        }
    }
853291
public function logout(): bool
    {
        //remove login data from session
        unset($this->session->login, $this->session->loginTime);

        //regenerate session id
        $this->session->regenerate();
        $this->logged = false;

        return true;
    }
584404
public function login()
    {

        // invoke the parent method
        if (parent::login()) {
            // if login has been successfully, setup our view of the user
            $name = new String($this->sharedState->get(SharedStateKeys::LOGIN_NAME));
            // query whether or not we alredy hava a principal
            if ($name instanceof PrincipalInterface) {
                $this->identity = name;
            } else {
                $name = $name->__toString();
                try {
                    $this->identity = $this->createIdentity($name);
                } catch (\Exception $e) {
                    throw new LoginException(sprintf('Failed to create principal: %s', $e->getMessage()));
                }
            }

            // return immediately
            return true;
        }

        // else, reset the login flag
        $this->loginOk = false;

        // array containing the username and password from the user's input
        list ($name, $password) = $this->getUsernameAndPassword();

        if ($name == null && $password == null) {
            $this->identity = $this->unauthenticatedIdentity;
        }

        if ($this->identity == null) {
            try {
                $this->identity = $this->createIdentity($name);
            } catch (\Exception $e) {
                throw new LoginException(sprintf('Failed to create principal: %s', $e->getMessage()));
            }

            // hash the user entered password if password hashing is in use
            if ($this->hashAlgorithm != null) {
                $password = $this->createPasswordHash($name, $password);
                // validate the password supplied by the subclass
                $expectedPassword = $this->getUsersPassword();
            }

            // validate the password
            if ($this->validatePassword($password, $expectedPassword) === false) {
                throw new FailedLoginException('Password Incorrect/Password Required');
            }
        }

        // query whether or not password stacking has been activated
        if ($this->getUseFirstPass()) {
            // add the username and password to the shared state map
            $this->sharedState->add(SharedStateKeys::LOGIN_NAME, $name);
            $this->sharedState->add(SharedStateKeys::LOGIN_PASSWORD, $this->credential);
        }

        $this->loginOk = true;
        return true;
    }
853766
public function isAdmin(): bool
    {
        return $this->isLoggedIn()
            && isset($this->session->get('user')['admin'])
            && $this->session->get('user')['admin'] === true;
    }
903341
public function login()
	{
		return $this->select_logins()
			->where( 'restore_id', $this->user->{$this->config->user_key} )
			->where( 'restore_token', $this->restore_key( $this->user ) )
			->limit( 1 )
			->run();
	}
577465
public function loggedIn()
    {
        if (parent::loggedIn()) {
            $account = new Account($_SESSION[ 'account' ]);

            if ($user = models('users')->findWhere(['username' => $account->username], 1)) {
                // Store Account Profile
                if ($profile = $user->profile) {
                    $account->store('profile', $profile);
                }

                // Store Account Role
                if ($role = $user->role) {
                    $account->store('role', new Role([
                        'label'       => $role->label,
                        'description' => $role->description,
                        'code'        => $role->code,
                        'authorities' => $role->authorities,
                    ]));
                }
            }
            
            // Store Globals Account
            globals()->store('account', $account);

            // Store Presenter Account
            if (services()->has('view')) {
                presenter()->store('account', $account);
            }

            return true;
        }

        return false;
    }
1372598
public function logout()
    {
        if (!$this->isActive()) {
            return false;
        }

        auth()->logout();

        // log back in as the original user
        $originalUserId = session()->get($this->originalUserKey);

        if ($originalUserId) {
            auth()->loginUsingId($originalUserId);
        }

        session()->forget($this->originalUserKey);
        session()->forget($this->isActiveKey);

        return true;
    }