private _returnUrl public function loginAction Tag appendTitle this- t

 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
private $_returnUrl;
public function loginAction(){
Tag::appendTitle($this->translator->query('session', ['title' => 'login']));
if($this->request->get('returnUrl')){
$this->_returnUrl = $this->request->get('returnUrl');
}
if ($this->request->isPost() AND $this->security->checkToken()) {
$validation = new \Phalcon\Validation();
$validation->add('emailField', new PresenceOf(array(
'message' => $this->translator->query('error', ['validator' => 'presenceOfEmail'])
)));
$validation->add('emailField', new Email(array(
'message' => $this->translator->query('error', ['validator' => 'emailInvalid'])
)));
$validation->add('passwordField', new PresenceOf(array(
'message' => $this->translator->query('error', ['validator' => 'presenceOfPassword'])
)));
$validation->add('passwordField', new StringLength(array(
'min' => 8,
'messageMinimum' => $this->translator->query('error', ['validator' => 'lengthPassword'])
)));
$validation->setFilters('emailField', 'striptags');
$validation->setFilters('passwordField', 'striptags');
$messages = $validation->validate($_POST);
if (count($messages)) {
foreach ($messages as $message) {
$this->flashSession->error($message);
}
}
else {
$user = Users::findFirstByEmail($this->request->getPost('emailField', 'email'));
if ($user !== false && $this->security->checkHash($this->request->getPost('passwordField'), $user->password)) {
$auth = $this->user->auth($user);
var_dump($this->_returnUrl);
die();
if($this->_returnUrl){
return $this->response->redirect($auth);
}
else {
return $this->response->redirect($this->_returnUrl);
}
}
else {
$this->flashSession->error($this->translator->query('error', 'loginFailed'));
}
}
}
}