Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class LoginController extends \Phalcon\Mvc\Controller
- {
- private function _registerSession(User $user)
- {
- $this->session->set('auth', array(
- 'loggedin' => true,
- 'id' => $user->id,
- 'username' => $user->username
- ));
- }
- public function indexAction()
- {
- if ($this->request->isPost()) {
- $login = $this->request->getPost('login');
- $password = $this->request->getPost('password');
- $user = Users::findFirstByLogin($login);
- if ($user) {
- if ($this->security->checkHash($password, $user->password)) {
- $this->_registerSession($user);
- $this->response->redirect('dashboard');
- }
- } else {
- $this->response->redirect('login');
- $this->security->hash(rand());
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment