-
Notifications
You must be signed in to change notification settings - Fork 0
/
LoginController.php
33 lines (29 loc) · 1023 Bytes
/
LoginController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
/**
* @author Artur Kyryliuk <mail@artur.work>
*/
namespace Auth\Controllers;
use Auth\Models\EmailUser;
class LoginController extends BaseAuthController
{
public function loginAction()
{
$login = $this->request->getPost('login', 'email', null, true);
$password = $this->request->getPost('password', 'string', null, true);
$rememberMe = (bool)$this->request->getPost('remember', 'string');
$user = EmailUser::findFirst([
'email = ?0',
'bind' => [$login]
]);
if (!$user || !$this->security->checkHash($password, $user->password))
{
$this->log->notice('Unsuccessful login ' . $login . ':' . $password);
$this->view->pick($this->_localizePath('content/auth'));
$this->flash->error(__('Wrong password!'));
return;
}
$this->log->info('Successful login ' . $login);
$this->_setToken($user, $rememberMe);
$this->_processAuthenticated($user);
}
}