public function indexAction() { if ($this->session->get('user')) { $this->response->redirect('/'); } if ($this->request->isPost()) { if ($this->request->getPost('accept') != 'y') { $this->flash->warning('Вы должны согласиться с условиями использования сервиса'); return; } $email = $this->request->getPost('email'); $user = Users::findFirst(array(array('email' => $email))); if ($user) { $this->flash->warning('Пользователь с таким email уже зарегистрирован'); return; } $user = new Users(); $user->email = $email; $password = $this->keyTools->RandString(8, 12); $user->pass = sha1($password); $user->key = sha1($this->keyTools->RandString(10, 20)); if ($user->save()) { $headers = 'From: noreply@kladr-api.ru' . "\n" . 'Reply-To: noreply@kladr-api.ru' . "\n" . 'Content-Type: text/html; charset="utf-8"'; $subject = 'Вы зарегистрированы на сайте КЛАДР API'; $subject = '=?utf-8?B?' . base64_encode($subject) . '?='; $message = 'Вы зарегистрированы на сайте КЛАДР API' . "<br/><br/>" . 'Ваш пароль: <strong>' . $password . '</strong>' . "<br/>" . 'Для входа на сайт пройдите по <a href="http://kladr-api.ru/login/">ссылке</a>'; $message = wordwrap($message, 70); mail($email, $subject, $message, $headers); } $this->session->set('user', $user->_id); $this->response->redirect("integration/"); } }
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 indexAction() { if ($this->request->isPost()) { $email = $this->request->getPost('email'); $password = $this->request->getPost('password'); $password = sha1($password); $user = Users::findFirst(array(array('email' => $email, 'pass' => $password))); if (!$user) { $this->flash->warning('Ошибка входа: неверно введены email или пароль.'); return; } $this->session->set('user', $user->_id); $this->response->redirect("integration"); } }
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; } } }