Ejemplo n.º 1
0
 /**
  * Handle login.
  *
  * @return bool True if the action was performed.
  */
 public function taskLogin()
 {
     /** @var Language $t */
     $t = $this->grav['language'];
     if ($this->authenticate($this->post)) {
         $this->login->setMessage($t->translate('PLUGIN_LOGIN.LOGIN_SUCCESSFUL'));
         $redirect = $this->grav['config']->get('plugins.login.redirect_after_login');
         if (!$redirect) {
             $redirect = $this->grav['uri']->referrer('/');
         }
         $this->setRedirect($redirect);
     } else {
         $user = $this->grav['user'];
         if ($user->username) {
             $this->setMessage($t->translate('PLUGIN_LOGIN.ACCESS_DENIED'), 'error');
         } else {
             $this->setMessage($t->translate('PLUGIN_LOGIN.LOGIN_FAILED'), 'error');
         }
     }
     return true;
 }