POST Login the user.

POST (:orchestra)/login

@return mixed
182430
public function login(Request $request, AuthenticateUser $authenticate, ThrottlesCommand $throttles)
    {
        $username = Authen::getIdentifierName();

        $input = $request->only([$username, 'password', 'remember']);

        $throttles->setRequest($request)->setLoginKey($username);

        return $authenticate($this, $input, $throttles);
    }
962319
public function login() {
        if ($this->request->is('post')) {
            $user = $this->Auth->identify();
            if ($user) {
                $this->Auth->setUser($user);
                return $this->redirect($this->Auth->redirectUrl());
            }
            $this->Flash->error(__('Your username or password is incorrect.'));
        }

        // Set signin layout from Builder.Layout
        $this->viewBuilder()->layout('signin');
        // Use the layout without Template 
        $this->render(false);
    }
1058606
public function actionTokenPost()
	{
		$model = new LoginForm;
		$model->username = Cii::get($_POST, 'email');
		$model->password = Cii::get($_POST, 'password');
		$model->twoFactorCode = Cii::get($_POST, '2fa', false);

		if (Cii::get($_POST, 'name', NULL) == NULL)
			throw new CHttpException(400, Yii::t('Api.user', 'Application name must be defined.'));
		else
			$model->app_name = Cii::get($_POST, 'name', 'api');

		if ($model->login())
		{
			$data = $model->getIdentity()->getUser()->getMetadataObject('api_key'.Cii::get($_POST, 'name'));
			if (get_class($data) === "UserMetadata")
				return $data->value;

			return false;
		}

		// Two factor authentication error code. A little more specific
		if ($model->needsTwoFactorAuth())
			return $this->returnError(412, Yii::t('Api.user', 'Unable to authenticate.'), false);
		
		return $this->returnError(403, Yii::t('Api.user', 'Unable to authenticate.'), false);
	}
239918
public function loginWithAction()
    {
        $return = $this->getReturnUri();
        $auth   = $this->getServiceLocator()
                       ->get( 'Zend\Authentication\AuthenticationService' );

        if ( $auth->hasIdentity() )
        {
            return $this->redirect()
                        ->toUrl( $this->getValidReturnUri( $return ) );
        }

        $request = $this->getRequest();
        $data    = $request->getQuery()
                           ->toArray();

        if ( $request->isPost() )
        {
            $data = array_merge( $data, $request->getPost()
                                                ->toArray() );
        }

        /* @var $sessm \Zend\Session\SessionManager */
        /* @var $logger \Zork\Log\LoggerManager */
        $sessm  = $this->getSessionManager();
        $logger = $this->getServiceLocator()
                       ->get( 'Zork\Log\LoggerManager' );
        $result = $this->getServiceLocator()
                       ->get( 'Grid\User\Authentication\Service' )
                       ->login( $data, $sessm, $auth );

        $messages   = $result->getMessages();
        $with       = empty( $messages['loginWith'] )
                    ? 'other'
                    : $messages['loginWith'];

        if ( $result->isValid() )
        {
            $sessm->regenerateId( false );

            $this->messenger()
                 ->add( 'user.form.login.success',
                        'user', Message::LEVEL_INFO );

            if ( $logger->hasLogger( 'application' ) )
            {
                $logger->getLogger( 'application' )
                       ->notice( 'user-login', array(
                           'successful' => true,
                           'loginWith'  => $with,
                       ) );
            }
        }
        else
        {
            foreach ( $messages as $index => $message )
            {
                if ( is_int( $index ) && is_string( $message ) )
                {
                    $this->messenger()
                         ->add( $message, false, Message::LEVEL_WARN );
                }
            }

            $this->messenger()
                 ->add( $this->getErrorMessageKey( $result->getCode() ),
                        'user', Message::LEVEL_ERROR );

            if ( $logger->hasLogger( 'application' ) )
            {
                $logger->getLogger( 'application' )
                       ->warn( 'user-login', array(
                           'successful' => false,
                           'loginWith'  => $with,
                       ) );
            }
        }

        if ( ! empty( $messages['registered'] ) )
        {
            $user = $result->getIdentity();

            $this->getServiceLocator()
                 ->get( 'Grid\Mail\Model\Template\Sender' )
                 ->prepare( array(
                     'template' => 'user.login-with',
                     'locale'   => $user->locale,
                 ) )
                 ->send( array(
                     'email'        => $user->email,
                     'display_name' => $user->displayName,
                     'confirm_url'  => null,
                 ), array(
                     $user->email   => $user->displayName,
                 ) );
        }

        if ( empty( $messages['returnUri'] ) )
        {
            if ( empty( $data['returnUri'] ) )
            {
                $returnUri = $return;
            }
            else
            {
                $returnUri = $data['returnUri'];
            }
        }
        else
        {
            $returnUri = $messages['returnUri'];
        }

        return $this->redirect()
                    ->toUrl( $this->getValidReturnUri( $returnUri ) );
    }
361738
public function login()
    {
        $isLoginFailure = false;

        if ($this->request->getMethod() == 'POST') {
            $token = $this->getParam('token');
            if (!isset($token, $_SESSION['login_token']) || $token !== $_SESSION['login_token']) {
                $isLoginFailure = true;
            } else {
                unset($_SESSION['login_token']);

                $user = $this->userStore->getByEmail($this->getParam('email'));

                if ($user && password_verify($this->getParam('password', ''), $user->getHash())) {
                    session_regenerate_id(true);
                    $_SESSION['phpci_user_id']    = $user->getId();
                    $response = new b8\Http\Response\RedirectResponse();
                    $response->setHeader('Location', $this->getLoginRedirect());
                    return $response;
                } else {
                    $isLoginFailure = true;
                }
            }
        }

        $form = new b8\Form();
        $form->setMethod('POST');
        $form->setAction(PHPCI_URL.'session/login');

        $email = new b8\Form\Element\Email('email');
        $email->setLabel(Lang::get('email_address'));
        $email->setRequired(true);
        $email->setContainerClass('form-group');
        $email->setClass('form-control');
        $form->addField($email);

        $pwd = new b8\Form\Element\Password('password');
        $pwd->setLabel(Lang::get('password'));
        $pwd->setRequired(true);
        $pwd->setContainerClass('form-group');
        $pwd->setClass('form-control');
        $form->addField($pwd);

        $pwd = new b8\Form\Element\Submit();
        $pwd->setValue(Lang::get('log_in'));
        $pwd->setClass('btn-success');
        $form->addField($pwd);

        $tokenValue = $this->generateToken();
        $_SESSION['login_token'] = $tokenValue;
        $token = new b8\Form\Element\Hidden('token');
        $token->setValue($tokenValue);
        $form->addField($token);

        $this->view->form = $form->render();
        $this->view->failed = $isLoginFailure;

        return $this->view->render();
    }
800468
public function loginAction()
    {
        $provider = $this->Request()->getParam('provider');

        if ($provider) {
            /** @var \Port1HybridAuth\Service\SingleSignOnService $singleSignOnService */
            $singleSignOnService = $this->container->get('port1_hybrid_auth.single_sign_on_service');
            $isUserLoggedIn = $singleSignOnService->loginAndRegisterVia($provider);

            if ($isUserLoggedIn) {
                return $this->redirect(
                    [
                        'controller' => $this->Request()->getParam('sTarget', 'account'),
                        'action' => $this->Request()->getParam('sTargetAction', 'index')
                    ]
                );
            }


            $this->forward('index', 'register', 'frontend', [
                'sTarget' => $this->Request()->getParam('sTarget')
            ]);
        } else {
            // @todo: redirect to referere or error?
        }
    }
1269331
protected function doLogin()
    {
        $connection = $this->connection;
        $user = $this->getParam('user');
        $password = $this->getParam('pass');

        return $this->retry(function () use ($connection, $user, $password) {
            $res = @ftp_login($connection, $user, $password);

            if (!$res) {
                throw new \RuntimeException("Login failed for user: ".$user);
            }
        });
    }
744681
protected static function login() :void {
		
		// look for users with this login
		$account = \Models\Accounts::getFirstEnabledWithLogin(
			Request::post( Config::get('security', 'login') )
		);
		// if the account does not exist/is not found
		if(!$account) {
			// we deny access
			self::refuse('Account does not exist or is disabled'); 
		}
		// if the account has been forced by that ip recently
		if($account->hasFailedLoginAttemptsRecentFrom(self::getSafeRemoteAddress())) {
			// extend the lock on the account
			$account->extendLoginBan();
			// refuse access
			self::refuse('Please wait '.Config::get('security', 'waiting_duration').' seconds before trying again');
		}
		// if the account has expired
		if($account->hasItsValidityExpired()) {
			// register that failure
			$account->registerFailedLoginAttemptFrom(self::getSafeRemoteAddress(), self::getSafeUserAgent());
			// refuse access
			self::refuse("Your account has expired, it was valid until {$account->get('account_expiration_date')}");	
		}
		// if the posted password doesn't match the account's password
		if(!$account->hasThisPassword(Request::post(Config::get('security', 'password')))) {
			// register that failure
			$account->registerFailedLoginAttemptFrom(self::getSafeRemoteAddress(), self::getSafeUserAgent());
			// refuse access
			self::refuse('Wrong password');
		}
		// if we failed to open a session
		if(!$account->tryOpeningSession()) {
			// we report that something is wrong
			self::refuse('Your session failed to open, make sure your browser accepts cookies', 500);
		}
		// then session has been opened
		else {
			// log the loggin action
			Logger::info("Account {$account->get('login')} has logged in");
			// put the user inside of us
			self::$_account = $account;
			// set the most basic authentication block as being true/passed
			self::$_granted = true;
			// if we have an url in the session, redirect to it (and remove it)
			!Session::has('previously_requested_url') ?: self::redirectToThePreviouslyRequestedUrl();
		}
		
	}
278759
public function login()
    {
        $this->authSessionId = $this->requestAuthSessionID($this->user,
            $this->password);
        return $this->lastResponseCode == 200;
    }
1130892
public function login()
    {
        $response = parent::soapCall('login', array($this->getCredentials()));

        $this->setLoginResult($response->getResult());

        $this->setOption('location', $this->loginResult->getServerUrl());

        $this->lastLoginTime = time();

        return $response;
    }
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);
    }
1152789
public function login()
    {
        $pass = $this->doc->__get("password");
        if($pass && $this->request->param('pass') === $pass){
            session('pass', md5($pass));
            $data = ['status' => '200', 'message' => '登录成功'];
        }else if(!$pass){
            $data = ['status' => '200', 'message' => '登录成功'];
        }else{
            $data = ['status' => '300', 'message' => '密码错误'];
        }
        return response($data, 200, [], 'json');
    }
738102
public function loginAction()
    {
        $return = $this->getReturnUri();
        $auth   = $this->getServiceLocator()
                       ->get( 'Zend\Authentication\AuthenticationService' );

        if ( $auth->hasIdentity() )
        {
            return $this->redirect()
                        ->toUrl( $this->getValidReturnUri( $return ) );
        }

        /* @var $form \Zend\Form\Form */
        $request = $this->getRequest();
        $data    = $request->getPost();
        $form    = $this->getServiceLocator()
                        ->get( 'Form' )
                        ->create( 'Grid\User\Login', array(
                            'returnUri' => $return,
                        ) );

        $form->setData( $data );

        if ( $request->isPost() )
        {
            if ( $form->isValid() )
            {
                /* @var $sessm \Zend\Session\SessionManager */
                /* @var $logger \Zork\Log\LoggerManager */
                $data   = $form->getData();
                $sessm  = $this->getSessionManager();
                $logger = $this->getServiceLocator()
                               ->get( 'Zork\Log\LoggerManager' );
                $result = $this->getServiceLocator()
                               ->get( 'Grid\User\Authentication\Service' )
                               ->login( $data, $sessm, $auth );

                $messages = $result->getMessages();

                if ( $result->isValid() )
                {
                    $sessm->regenerateId( false );

                    $this->messenger()
                         ->add( 'user.form.login.success',
                                'user', Message::LEVEL_INFO );

                    if ( $logger->hasLogger( 'application' ) )
                    {
                        $logger->getLogger( 'application' )
                               ->notice( 'user-login', array(
                                   'successful' => true,
                               ) );
                    }
                }
                else
                {
                    foreach ( $messages as $index => $message )
                    {
                        if ( is_int( $index ) && is_string( $message ) )
                        {
                            $this->messenger()
                                 ->add( $message, false, Message::LEVEL_WARN );
                        }
                    }

                    $this->messenger()
                         ->add( $this->getErrorMessageKey( $result->getCode() ),
                                'user', Message::LEVEL_ERROR );

                    if ( $logger->hasLogger( 'application' ) )
                    {
                        $logger->getLogger( 'application' )
                               ->warn( 'user-login', array(
                                   'successful' => false,
                               ) );
                    }
                }

                if ( empty( $messages['returnUri'] ) )
                {
                    if ( empty( $data['returnUri'] ) )
                    {
                        $returnUri = $return;
                    }
                    else
                    {
                        $returnUri = $data['returnUri'];
                    }
                }
                else
                {
                    $returnUri = $messages['returnUri'];
                }

                return $this->redirect()
                            ->toUrl( $this->getValidReturnUri( $returnUri ) );
            }
        }

        $this->plugin( 'layout' )
             ->setMiddleLayout( 'layout/middle/center' );

        return array(
            'form'      => $form,
            'display'   => $this->getServiceLocator()
                                ->get( 'Config' )
                                     [ 'modules' ]
                                     [ 'Grid\User' ]
                                     [ 'display' ]
        );
    }
783062
public function loginWith()
    {
        $providerName = $_REQUEST["provider"];
        $redirect = $_GET['redirect'];

        $userProfile = $this->getAuthProvider()->authenticate($providerName);

        if ($userProfile instanceof Exception) {
            $this->getView()->set('exception', $userProfile);
        } else {
            $userExist = User_Logins::instance()->getUserByProvider($providerName, $userProfile->identifier);

            if (!$userExist) {
                $this->redirect(
                    $this->getModelManager()->getOAuthLinkURL([
                        'provider' => $providerName,
                        'redirect' => $redirect
                    ]));
            }

            $userExist->doAuthentication();

            $this->afterLoginRedirect();
        }
    }
924143
public static function isLoggedIn()
    {
        // Check to see if Symphony exists, or if we already have an Author instance.
        if (is_null(self::$_instance) || self::$Author) {
            return true;
        }

        // No author instance found, attempt to log in with the cookied credentials
        return self::login(self::$Cookie->get('username'), self::$Cookie->get('pass'), true);
    }
1344081
public function loginAction()
    {
        if (!$this->getSecurityContext()->hasCustomerUser()) {
            $request = $this->getRequest();
            $customerLoginForm = new CustomerLogin($request);

            try {
                $form = $this->validateForm($customerLoginForm, "post");

                // If User is a new customer
                if ($form->get('account')->getData() == 0 && $form->get("email")->getErrors()->count() == 0) {
                    return $this->generateRedirectFromRoute(
                        "customer.create.process",
                        ["email" => $form->get("email")->getData()]
                    );
                } else {
                    try {
                        $authenticator = new CustomerUsernamePasswordFormAuthenticator($request, $customerLoginForm);

                        /** @var Customer $customer */
                        $customer = $authenticator->getAuthentifiedUser();

                        $this->processLogin($customer);

                        if (intval($form->get('remember_me')->getData()) > 0) {
                            // If a remember me field if present and set in the form, create
                            // the cookie thant store "remember me" information
                            $this->createRememberMeCookie(
                                $customer,
                                $this->getRememberMeCookieName(),
                                $this->getRememberMeCookieExpiration()
                            );
                        }

                        return $this->generateSuccessRedirect($customerLoginForm);

                    } catch (UsernameNotFoundException $e) {
                        $message = $this->getTranslator()->trans(
                            "Wrong email or password. Please try again",
                            [],
                            Front::MESSAGE_DOMAIN
                        );
                    } catch (WrongPasswordException $e) {
                        $message = $this->getTranslator()->trans(
                            "Wrong email or password. Please try again",
                            [],
                            Front::MESSAGE_DOMAIN
                        );
                    } catch (CustomerNotConfirmedException $e) {
                        if ($e->getUser() !== null) {
                            // Send the confirmation email again
                            $this->getDispatcher()->dispatch(
                                TheliaEvents::SEND_ACCOUNT_CONFIRMATION_EMAIL,
                                new CustomerEvent($e->getUser())
                            );
                        }
                        $message = $this->getTranslator()->trans(
                            "Your account is not yet confirmed. A confirmation email has been sent to your email address, please check your mailbox",
                            [],
                            Front::MESSAGE_DOMAIN
                        );
                    } catch (AuthenticationException $e) {
                        $message = $this->getTranslator()->trans(
                            "Wrong email or password. Please try again",
                            [],
                            Front::MESSAGE_DOMAIN
                        );
                    }

                }
            } catch (FormValidationException $e) {
                $message = $this->getTranslator()->trans(
                    "Please check your input: %s",
                    ['%s' => $e->getMessage()],
                    Front::MESSAGE_DOMAIN
                );
            } catch (\Exception $e) {
                $message = $this->getTranslator()->trans(
                    "Sorry, an error occured: %s",
                    ['%s' => $e->getMessage()],
                    Front::MESSAGE_DOMAIN
                );
            }

            Tlog::getInstance()->error(
                sprintf(
                    "Error during customer login process : %s. Exception was %s",
                    $message,
                    $e->getMessage()
                )
            );

            $customerLoginForm->setErrorMessage($message);

            $this->getParserContext()->addForm($customerLoginForm);

            if ($customerLoginForm->hasErrorUrl()) {
                return $this->generateErrorRedirect($customerLoginForm);
            }
        }
    }
46397
public function login()
    {
        if ($this->validate()) {
            $user = $this->getUser();
            $user->detachBehavior('LogBehavior');
            
            // update user model
            $user->updateAttributes([
                'force_reload' => false,
                'login_attempt' => 0,
                'login_attempt_lock_expiration' => null,
                'auth_token' => Yii::$app->security->hashData(Yii::$app->security->generateRandomString(), $user->password_salt),
            ]);
            
            // kill prev user logins
            UserLogin::updateAll(['is_destroyed' => true], ['user_id' => $user->id]);
            
            // create new user login
            $login = new UserLogin([
                'auth_token' => $user->auth_token,
                'user_id' => $user->id,
                'is_destroyed' => false,
            ]);
            $login->save();
            
            // refresh user online list
            UserOnline::refreshUser($user, 'login');
            return $user;
        }
        
        return false;
    }