public function loginAction() { $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); $this->assets->collection('admin-login-css')->addCss(__DIR__ . '/../assets/login.css')->setLocal(true)->addFilter(new \Phalcon\Assets\Filters\Cssmin())->setTargetPath(PUBLIC_PATH . '/assets/admin-login.css')->setTargetUri('assets/admin-login.css'); $form = new LoginForm(); if ($this->request->isPost()) { if ($form->isValid($this->request->getPost())) { $login = $this->request->getPost('login', 'string'); $password = $this->request->getPost('password', 'string'); $user = AdminUser::findFirst("login='******'"); if ($user) { if ($user->checkPassword($password)) { if ($user->isActive()) { $this->session->set('auth', $user->getAuthData()); $this->flash->success($this->helper->translate("Wellcome to adminpanel")); $this->response->redirect('admin'); return $this->response->send(); } else { $this->flash->error($this->helper->translate("User isn't active")); } } else { $this->flash->error($this->helper->translate("Wrong login/password")); } } else { $this->flash->error($this->helper->translate("user not found Wrong login/password")); } } else { foreach ($form->getMessages() as $message) { $this->flash->error($message); } } } }
public function loginAction() { $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); $form = new LoginForm(); if ($this->request->isPost()) { if ($form->isValid($this->request->getPost())) { $login = $this->request->getPost('login', 'string'); $password = $this->request->getPost('password', 'string'); $user = AdminUser::findFirst("login='******'"); if ($user) { if ($user->checkPassword($password)) { if ($user->isActive()) { $this->session->set('auth', $user->getAuthData()); $this->flash->success($this->helper->translate("Приветствуем в административной панели управления!")); $this->response->redirect('admin'); return $this->response->send(); } else { $this->flash->error($this->helper->translate("Пользователь не активирован")); } } else { $this->flash->error($this->helper->translate("Неверный логин или пароль")); } } else { $this->flash->error($this->helper->translate("Неверный логин или пароль")); } } else { foreach ($form->getMessages() as $message) { $this->flash->error($message); } } } }
private function getRole() { $auth = $this->session->get('auth'); if (!$auth) { $role = 'guest'; } else { if ($auth->admin_session == true) { $role = \Admin\Model\AdminUser::getRoleById($auth->id); } else { $role = 'member'; } } return $role; }
public function deleteAction($id) { $model = AdminUser::findFirst("id = {$id}"); if (!$model) { $this->response->redirect('admin/admin-user'); return $this->response->send(); } if ($this->request->isPost()) { $model->delete(); $this->flash->warning($this->helper->translate('Administrator <b>%login%</b> deleted', array('login' => $model->getLogin()))); $this->response->redirect('admin/admin-user'); return $this->response->send(); } $this->view->model = $model; $this->view->title = $this->helper->translate('Delete Administrator'); $this->helper->title()->append($this->view->title); }
public function deleteAction($id) { $model = AdminUser::findFirst($id); if (!$model) { return $this->redirect($this->url->get() . 'admin/admin-user'); } if ($model->getLogin() == 'admin') { $this->flash->error('Admin user cannot be deleted'); return $this->redirect($this->url->get() . 'admin/admin-user'); } if ($this->request->isPost()) { $model->delete(); $this->flash->warning('Deleting user <b>' . $model->getLogin() . '</b>'); return $this->redirect($this->url->get() . 'admin/admin-user'); } $this->view->model = $model; $this->helper->title($this->helper->at('Delete User'), true); }
public function loginAction() { $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); $form = new LoginForm(); if ($this->request->isPost()) { if ($this->security->checkToken()) { if ($form->isValid($this->request->getPost())) { $login = $this->request->getPost('login', 'string'); $password = $this->request->getPost('password', 'string'); $user = AdminUser::findFirst("login='******'"); if ($user) { if ($user->checkPassword($password)) { if ($user->isActive()) { $this->session->set('auth', $user->getAuthData()); $this->flash->success($this->helper->translate("Welcome to the administrative control panel!")); return $this->redirect($this->url->get() . 'admin'); } else { $this->flash->error($this->helper->translate("User is not activated yet")); } } else { $this->flash->error($this->helper->translate("Incorrect login or password")); } } else { $this->flash->error($this->helper->translate("Incorrect login or password")); } } else { foreach ($form->getMessages() as $message) { $this->flash->error($message); } } } else { $this->flash->error($this->helper->translate("Security errors")); } } $this->view->form = $form; }