| | 116 | == Doing Stuff After User login == |
| | 117 | |
| | 118 | To do stuff after login, make sure the route /login is in the app/config/routes.php |
| | 119 | {{{ |
| | 120 | #!php |
| | 121 | Router::connect('/login', array('controller' => 'users', 'action' => 'login')); |
| | 122 | }}} |
| | 123 | |
| | 124 | Disable the autoRedirect in app_controller.php |
| | 125 | {{{ |
| | 126 | #!php |
| | 127 | public function beforeFilter() |
| | 128 | { |
| | 129 | $this->Auth->autoRedirect = false; |
| | 130 | ..... |
| | 131 | } |
| | 132 | }}} |
| | 133 | |
| | 134 | Create a login action in users controller (the controller and action can be change by changing the value in the route created above: |
| | 135 | {{{ |
| | 136 | #!php |
| | 137 | class UsersController extends AppController |
| | 138 | { |
| | 139 | ..... |
| | 140 | function login() |
| | 141 | { |
| | 142 | if ($this->Auth->isAuthorized()) { |
| | 143 | // after login stuff |
| | 144 | } |
| | 145 | } |
| | 146 | } |
| | 147 | }}} |