Bin will be removed on June 1, 2014 in favor of http://gist.github.com. Please save all your pastes before then. So long, and thanks for all the fish!×
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
    My app_controller
    cake/libs/controller/app_controller.php
*/
 
<?php
class AppController extends Controller {
        public function beforeFilter() {
        $this->__authSetup();
    }
 
    /**
     * Sets up Auth related configuration
     */
    private function __authSetup() {
        $this->Auth->loginAction = array(
            'controller' => 'users',
            'action' => 'login',  
            'admin' => false
        );
        $this->Auth->loginRedirect = array(
            'controller' => 'products',
            'action' => 'index',
            'admin' => true
        );
        $this->Auth->logoutRedirect = array(
            'controller' => 'users',
            'action' => 'login',
            'admin' => false
        );
        $this->Auth->userModel = 'User';  
        //$this->Auth->autoRedirect = false;
        $this->Auth->loginError = __('Invalid username or password', true);
        $this->Auth->authError = __('Access denied', true);
        }
    }
}
?>
 
 
/*
    My model
    app/models/user.php
*/
 
<?php
class User extends AppModel {
        var $name = 'User';
}
?>
 
 
/*
    My controller
    app/controllers/users_controller.php
*/
 
<?php
        class UsersController extends AppController {
                var $name = 'Users';
                var $components = array('Auth');
                //var $helpers = array('Form');
                function login() {
                        $this->layout = 'layout';
                        $this->pageTitle = 'Sapo Hey! In&iacute;cio';
                }
                function logout() {
                        $this->redirect($this->Auth->logout());
                }
        }
?>
 
 
/*
    My view
    app/views/users/login.ctp
*/
 
<?php
    if  ($session->check('Message.auth')) $session->flash('auth');
    echo $form->create('User', array('action' => 'login'));
    echo $form->input('ntelemovel');
    echo $form->input('password');
    echo $form->end('Login');
?>
 
 
 
/*
    http://m.sapohey.labs.sapo.pt
*/