public function getAuth() { $id = $this->session->get('user'); $user = $id ? Users::findById($id) : null; if ($user) { return '<a href="/logout/" class="btr-reg sing-out">Выйти</a>' . '<a href="" class="btr-reg recovery" style="margin-right: 10px;">Мои данные</a>' . '<a href="/personal/" class="btn-enter user">Мои ключи</a>'; } else { return '<a href="/register/" class="btr-reg sing-in">Создать аккаунт</a>' . '<a href="/login/" class="btn-enter login">Войти</a>'; } }
public function indexAction() { $id = $this->session->get('user'); if (!$id) { $this->session->remove('user'); $this->response->redirect('register'); } $user = Users::findById($id); if (!$user) { $this->session->remove('user'); $this->response->redirect('register'); } $this->view->setVar("user", $user); }
public function changeAction() { $this->view->disable(); if ($this->request->isPost()) { $id = $this->session->get('user'); if (!$id) { $this->session->remove('user'); print 'Для смены пароля нужно авторизоваться'; return; } $user = Users::findById($id); $old = $this->request->getPost('old'); $new = $this->request->getPost('new'); $repeat = $this->request->getPost('repeat'); if (empty($old)) { print 'Введите старый пароль'; return; } $old = sha1($old); if ($old != $user->pass) { print 'Неверно введён старый пароль'; return; } if (empty($new)) { print 'Введите новый пароль'; return; } if (empty($repeat)) { print 'Повторите новый пароль'; return; } if ($new != $repeat) { print 'Неверно введён повтор нового пароля'; return; } $user->pass = sha1($new); if ($user->save()) { print 'y'; } else { print 'Произошла ошибка при сохранении нового пароля. Попробуйте ещё раз.'; } } }
public function isAuthed() { $id = $this->session->get('user'); $user = $id ? Users::findById($id) : null; return $user ? true : false; }
public function indexAction() { $id = $this->session->get('user'); $user = $id ? Users::findById($id) : null; $this->view->setVar("authorized", $user ? true : false); }
public function domainkeyreloadAction() { $this->view->disable(); if ($this->request->isPost() && $this->request->isAjax()) { $id = $this->session->get('user'); if (!$id) { return; } $user = Users::findById($id); if (!$user) { return; } $key = sha1($this->keyTools->RandString(10, 20)); $user->domainkey = $key; if ($user->save()) { print $key; } } }