CakeDC\Users\Controller\Traits\LoginTrait::login PHP Method

login() public method

Login user
public login ( ) : mixed
return mixed
    public function login()
    {
        $event = $this->dispatchEvent(UsersAuthComponent::EVENT_BEFORE_LOGIN);
        if (is_array($event->result)) {
            return $this->_afterIdentifyUser($event->result);
        }
        if ($event->isStopped()) {
            return $this->redirect($event->result);
        }
        $socialLogin = $this->_isSocialLogin();
        $googleAuthenticatorLogin = $this->_isGoogleAuthenticator();
        if ($this->request->is('post')) {
            if (!$this->_checkReCaptcha()) {
                $this->Flash->error(__d('CakeDC/Users', 'Invalid reCaptcha'));
                return;
            }
            $user = $this->Auth->identify();
            return $this->_afterIdentifyUser($user, $socialLogin, $googleAuthenticatorLogin);
        }
        if (!$this->request->is('post') && !$socialLogin) {
            if ($this->Auth->user()) {
                $msg = __d('CakeDC/Users', 'You are already logged in');
                $this->Flash->error($msg);
                $url = $this->Auth->redirectUrl();
                return $this->redirect($url);
            }
        }
    }