login action
GET | POST

@return void
10067
public function login()
    {
        if ($this->request->is('post')) {
            $this->loadModel('Wasabi/Core.LoginLogs');
            $clientIp = $this->request->clientIp();
            $ipIsBlocked = $this->LoginLogs->ipIsBlocked($clientIp);

            if ($ipIsBlocked) {
                $errorMsg = __d('wasabi_core', 'You made too many failed login attempts in a short period of time. Please try again later.');
            }

            if (!$ipIsBlocked && ($user = $this->Auth->identify())) {
                if ((bool)$user['verified'] === false) {
                    $message = __d(
                        'wasabi_core',
                        'Please verify your email address or request a {0}.',
                        '<a href="' . Router::url(['plugin' => 'Wasabi/Core', 'controller' => 'Users', 'action' => 'requestNewVerificationEmail']) . '">' . __d('wasabi_core', 'new verification email') . '</a>'
                    );
                    unset($this->request->data['password']);
                    $this->Flash->warning($message, 'auth', false);
                } elseif ((bool)$user['active'] === false) {
                    $message = __d(
                        'wasabi_core',
                        'Your account has not yet been activated. Once your account has been checked by an administrator, you will receive a notification email.'
                    );
                    unset($this->request->data['password']);
                    $this->Flash->warning($message, 'auth', false);
                } else {
                    $this->Auth->setUser($user);
                    $this->request->session()->write('loginTime', time());
                    if (!$this->request->is('ajax')) {
                        $this->Flash->success(__d('wasabi_core', 'Welcome back.'), 'auth');
                        if (($redirectUrl = $this->Auth->redirectUrl()) === '/backend/heartbeat') {
                            $this->redirect(['plugin' => 'Wasabi/Core', 'controller' => 'Dashboard', 'action' => 'index']);
                        } else {
                            $this->redirect($redirectUrl);
                        }
                        return;
                    }
                }
            } else {
                unset($this->request->data['password']);
                $this->request->session()->write('data.login', $this->request->data());
                if (!$ipIsBlocked) {
                    $identityField = Wasabi::setting('Core.Auth.identity_field');
                    $this->dispatchEvent('Auth.failedLogin', [$clientIp, $identityField, $this->request->data[$identityField]]);
                    $errorMsg = __d('wasabi_core', 'Email or password is incorrect.');
                }

                if (isset($errorMsg)) {
                    $this->Flash->error($errorMsg, 'auth', false);
                }
                if (!$this->request->is('ajax')) {
                    $this->redirect(['action' => 'login']);
                    return;
                }
            }

            if ($this->request->is('ajax')) {
                $this->set([
                    'status' => 200,
                    '_serialize' => ['status']
                ]);
                $flashType = $this->request->session()->read('Flash.auth.0.params.type');
                if ($flashType === 'warning') {
                    $this->set('redirect', Router::url('/' . $this->request->url, true));
                    $this->viewVars['_serialize'][] = 'redirect';
                }
                if ($flashType === 'error') {
                    $this->set('content', (new AppView($this->request, $this->response, $this->eventManager()))->element('Wasabi/Core.login-form-ajax'));
                    $this->viewVars['_serialize'][] = 'content';
                }
            }
        } else {
            if ($this->request->session()->check('data.login')) {
                $this->request->data = (array)$this->request->session()->read('data.login');
                $this->request->session()->delete('data.login');
            }
        }

        if (!$this->request->is('ajax')) {
            $this->render(null, 'Wasabi/Core.support');
        }
    }
1038900
public function login()
    {
        $_SESSION['auth'] = 'login';

        if ($this->userStore->find()->count() === 0) {
            return $this->redirect('/setup');
        }

        Event::trigger('beforeLogin', $this);

        if ($this->request->getMethod() == 'POST') {
            $user = Store::get('User')->getByEmail($this->getParam('email'));

            if ($user && password_verify($this->getParam('password', ''), $user->getHash())) {
                $_SESSION['user_id'] = $user->getId();

                $url = $this->config->get('site.full_admin_url');

                if (isset($_SESSION['previous_url'])) {
                    $url = $_SESSION['previous_url'];
                }

                return $this->redirect($url);
            } else {
                Event::trigger('loginFailed', $this->view);
                $this->template->errorMessage = 'Your email address or password were incorrect.';
            }
        }
    }
308070
private function login()
    {
        if ($this->loggedIn) {
            return;
        }

        if (array_key_exists('rsakey', $this->sshConfig)) {
            $this->loginWithRsaKey();
        } elseif (array_key_exists('password', $this->sshConfig)) {
            $this->loginWithPassword();
        }

        $this->loggedIn = $this->validate();
    }
990091
public function actionLogin()
	{
		$model=new LoginForm;

		// if it is ajax validation request
		if(isset($_POST['ajax']) && $_POST['ajax']==='login-form')
		{
			echo CActiveForm::validate($model);
			Yii::app()->end();
		}

		// collect user input data
		if(isset($_POST['LoginForm']))
		{
			$model->attributes=$_POST['LoginForm'];
			// validate user input and redirect to the previous page if valid
			if($model->validate() && $model->login())
				$this->redirect(Yii::app()->user->returnUrl);
		}
		// display the login form
		$this->render('login',array('model'=>$model));
	}
730800
public function actionLogin()
    {
        /** @var \amnah\yii2\user\models\forms\LoginForm $model */
        $model = $this->module->model("LoginForm");

        // load post data and login
        $post = Yii::$app->request->post();
        if ($model->load($post) && $model->validate()) {
            $returnUrl = $this->performLogin($model->getUser(), $model->rememberMe);
            return $this->redirect($returnUrl);
        }

        return $this->render('login', compact("model"));
    }
1218615
public function indexAction()
    {
        if ($this->auth->hasIdentity()) {
            return $this->redirect()->toRoute('lang');
        }

        $viewModel        = new ViewModel();
        /* @var $loginForm Login */
        $loginForm        = $this->forms[self::LOGIN];
        /* @var $registerForm Register */
        $registerForm = $this->forms[self::REGISTER];

        /* @var $request \Zend\Http\Request */
        $request   = $this->getRequest();

        if ($request->isPost()) {
            $data                          = $this->params()->fromPost();
            $adapter                       = $this->userLoginAdapter;
            // inject suffixes via shared Events
            $loginSuffix                   = '';
            // @TODO: replace this by the Plugin LoginFilter
            $e                             = $this->getEvent();
            $loginSuffixResponseCollection = $this->getEventManager()->trigger('login.getSuffix', $e);
            if (!$loginSuffixResponseCollection->isEmpty()) {
                $loginSuffix = $loginSuffixResponseCollection->last();
            }

            $loginForm->setData($data);
            if (array_key_exists('credentials', $data) &&
                array_key_exists('login', $data['credentials']) &&
                array_key_exists('credential', $data['credentials'])) {
                $adapter->setIdentity($data['credentials']['login'] . $loginSuffix)
                    ->setCredential($data['credentials']['credential']);
            }
            
            $auth   = $this->auth;
            $result = $auth->authenticate($adapter);
            
            
            if ($result->isValid()) {
                $user = $auth->getUser();
                $language = $this->locale->detectLanguage($request, $user);
                $this->logger->info('User ' . $user->getLogin() . ' logged in');
                
                $ref = $this->params()->fromQuery('ref', false);

                if ($ref) {
                    $ref = urldecode($ref);
                    $url = preg_replace('~/[a-z]{2}(/|$)~', '/' . $language . '$1', $ref);
                    $url = $request->getBasePath() . $url;
                } else {
                    $urlHelper = $this->viewHelperManager->get('url');
                    $url = $urlHelper('lang', array('lang' => $language));
                }
                $this->notification()->success(/*@translate*/ 'You are now logged in.');
                return $this->redirect()->toUrl($url);
            } else {
                $loginName = $data['credentials']['login'];
                if (!empty($loginSuffix)) {
                    $loginName = $loginName . ' (' . $loginName . $loginSuffix . ')';
                }
                $this->logger->info('Failed to authenticate User ' . $loginName);
                $this->notification()->danger(/*@translate*/ 'Authentication failed.');
            }
        }
        
        $ref = $this->params()->fromQuery('ref', false);
        
        if ($ref) {
            $req = $this->params()->fromQuery('req', false);
            if ($req) {
                $this->getResponse()->setStatusCode(Response::STATUS_CODE_401);
                $viewModel->setVariable('required', true);
            }
            $viewModel->setVariable('ref', $ref);
        }

        $allowRegister = $this->options->getEnableRegistration();
        $allowResetPassword = $this->options->getEnableResetPassword();
        if (isset($allowRegister)) {
            $viewModel->setVariables(
                [
                    'allowRegister' => $allowRegister,
                    'allowResetPassword' => $allowResetPassword
                ]
            );
        }

        $viewModel->setVariable('loginForm', $loginForm);
        $viewModel->setVariable('registerForm', $registerForm);

        /* @deprecated use loginForm instead of form in your view scripts */
        $viewModel->setVariable('form', $loginForm);


        return $viewModel;
    }
617470
public function index()
    {
        $this->defaultData();
        $formContainer = new tao_actions_form_PasswordRecovery();
        $form = $formContainer->getForm();

        if ($form->isSubmited() && $form->isValid()) {
            $mail = $form->getValue('userMail');
            $user = $this->getPasswordRecovery()->getUser(GenerisRdf::PROPERTY_USER_MAIL, $mail);

            if ($user !== null) {
                $this->logInfo("User requests a password (user URI: {$user->getUri()})");
                $this->sendMessage($user);
            } else {
                $this->logInfo("Unsuccessful recovery password. Entered e-mail address: {$mail}.");
                $this->setData('header', __('An email has been sent'));
                $this->setData('info', __('A message with further instructions has been sent to your email address: %s', $mail));
            }
            $this->setData('content-template', array('passwordRecovery/password-recovery-info.tpl', 'tao'));
        } else {
            $this->setData('form', $form->render());
            $this->setData('content-template', array('passwordRecovery/index.tpl', 'tao'));
        }

        $this->setView('layout.tpl', 'tao');
    }
238400
public function postRegister()
    {
        if( $this->userForm->register(Input::all(),false) )
        {
            return Redirect::route('cpanel.login')
                ->with('success', Lang::get('cpanel::users.register_success'));
        }

        return Redirect::back()
            ->withInput()
            ->withErrors($this->userForm->getErrors());

    }
197625
public function doLogin()
    {
        $remember = Input::post('remember', false);
        $email    = Input::post('email');
        $redirect = Input::post('redirect');
        $redirect = ($redirect) ? $redirect : 'admin';

        try{
            $credential = array(
                'email'     => $email,
                'password'  => Input::post('password')
            );

            // Try to authenticate the user
            $user = Sentry::authenticate($credential, false);

            if($remember){
                Sentry::loginAndRemember($user);
            }else{
                Sentry::login($user, false);
            }

            Response::redirect($this->siteUrl($redirect));
        }catch(\Exception $e){
            App::flash('message', $e->getMessage());
            App::flash('email', $email);
            App::flash('redirect', $redirect);
            App::flash('remember', $remember);

            Response::redirect($this->siteUrl('login'));
        }
    }
278759
public function login()
    {
        $this->authSessionId = $this->requestAuthSessionID($this->user,
            $this->password);
        return $this->lastResponseCode == 200;
    }
657253
public function postLogin()
    {
        $loginData = Binput::only(['username', 'password', 'remember_me']);

        // Login with username or email.
        $loginKey = filter_var($loginData['username'], FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
        $loginData[$loginKey] = Arr::pull($loginData, 'username');

        $rememberUser = Arr::pull($loginData, 'remember_me') === '1';

        // Validate login credentials.
        if (Auth::validate($loginData)) {
            Auth::once($loginData);

            if (Auth::user()->hasTwoFactor) {
                Session::put('2fa_id', Auth::user()->id);

                return cachet_redirect('auth.two-factor');
            }

            Auth::attempt($loginData, $rememberUser);

            event(new UserLoggedInEvent(Auth::user()));

            return Redirect::intended(cachet_route('dashboard'));
        }

        return cachet_redirect('auth.login')
            ->withInput(Binput::except('password'))
            ->withError(trans('forms.login.invalid'));
    }
377396
protected function post_data($action)
  {
      $this->post['METHOD'] = $action;
      $this->post['VERSION'] = $this->version;
      $this->post['PWD'] = $this->options['password'];
      $this->post['USER'] = $this->options['login'];
      $this->post['SIGNATURE'] = $this->options['signature'];

      return $this->urlize($this->post);
  }
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');
    }
635956
function check_loginout()
	{
		switch (arg('action'))
		{
			case 'login':
				$this->login(arg('user'), $this->password_hash(arg('password')), arg('autologin', 'int'));
				HTTP::redirect($this->request['url']);
			break;
			case 'logout':
				$this->logout(true);
				HTTP::redirect($this->root.'admin/');
			break;
		}
	}
219911
public function postLogin()
    {
        $input = Input::all();

        // Get the columns we will authenticate against
        $columns = config('bumble.auth_columns');

        $creds = [];

        foreach ($columns as $column)
        {
            $creds[$column] = $input[$column];
        }

        // Log the user in
        if (Auth::attempt($creds))
        {
            return Redirect::route('bumble.dashboard');
        }

        return Redirect::back()->with('login_error', 'There was something wrong with your credentials')->withInput();
    }
1157522
public function getPostLogin()
    {
        $title      = "Login";
        $view       = $this->di->get("view");
        $pageRender = $this->di->get("pageRender");
        $form       = new LoginForm($this->di);

        $form->check();

        $data = [
            "form" => $form->getHTML(),
        ];

        $view->add("user/login", $data);

        $pageRender->renderPage(["title" => $title]);
    }
382670
public function loginAction()
    {
        $request = $this->getRequest();
        $session = $request->getSession();
        if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
            $error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
        } else {
            $error = $session->get(SecurityContext::AUTHENTICATION_ERROR);
            $session->remove(SecurityContext::AUTHENTICATION_ERROR);
        }

        $view = $this
            ->view()
            ->setTemplate($this->config->getTemplate('login.html'))
            ->setTemplateVar($this->config->getPluralResourceName())
            ->setData(array(
                'last_username' => $session->get(SecurityContext::LAST_USERNAME),
                'error'         => $error
            ));

        return $this->handleView($view);
    }