public function loginAction() { if ($this->isPost()) { $password = User::generatePassword($this->params['username'], $this->params['password']); $user = $this->repo(User::classname())->byLoginAndPassword($this->params['username'], $password); if ($user instanceof User) { $this->_session->set('user', $user->id()); $url = $this->_session->get('referer') ?: '/'; $this->redirect($url); } else { $this->alert(Alert::ERROR, 'Error logging in'); } } }