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 |
<?php
class AppController extends Controller {
function beforeFilter() {
$this->Auth->authorize='actions';
}
}
?>
/*******************/
<?php
class UsersController extends AppController {
var $name = 'Users';
var $components = array('Cookie', 'RequestHandler', 'Security'); // removing Security corrects problem
function beforeFilter() {
parent::beforeFilter();
//$this->Auth->allow('register');
$this->Auth->autoRedirect = false;
$this->Cookie->name = 'Bonafic';
//$this->Security->disabledFields = array('active');
}
function login() {
if ($this->Auth->user()) {
$cookie['username'] = $this->data['User']['username'];
$cookie['password'] = $this->data['User']['password'];
$this->Cookie->write('Auth.User', $cookie);
$this->User->id = $this->Auth->user('id');
$this->User->saveField('last_login_ip', $this->RequestHandler->getClientIP());
}
$this->redirect($this->Auth->redirect());
}
$cookie = $this->Cookie->read('Auth.User');
if ($this->Auth->login($cookie)) {
$this->Session->del('Message.auth');
$this->redirect($this->Auth->redirect());
}
}
}
}
function register() {
}
function logout() {
$this->Session->setFlash('Logged out.');
$this->redirect($this->Auth->logout());
}
?> |
