Basic user authentication
January 3, 2009 – 4:00 pmToday I got the basic user authentication going for the Recipe Manager using this tutorial. Users Controller class UsersController extends AppController { var $name = "Users"; //var $helpers = array('Html', 'Form'); function index() { } function beforeFilter() { $this->__validateLoginStatus(); } function login() { if(empty($this->data) == false) { if(($user = $this->User->validateLogin($this->data['User'])) == true) { $this->Session->write('User', $user); $this->Session->setFlash('You\'ve successfully logged in.'); $this->redirect('/recipes/'); exit(); } else { $this->Session->setFlash('Sorry, the information you\'ve entered is incorrect.'); exit(); } } } function register() { if (!empty($this->data)) { //Sanitize::clean($this->data); $this->data['User']['password'] = md5($this->data['User']['password']); $this->User->create(); // ...