I have a table named "userinformations ". I want to use "emailid" and
"password" fields as login credentials for my site.
Have added the below codes in respective files.

 But when I login I am in same login page with a message "You are not
authorized to access that location."


app/app_controller.php

class AppController extends Controller {

        var $components = array('Auth','Session');

        function beforeFilter() {
                $this->Auth->userModel = 'Userinformation';
                Security::setHash("md5");
                $this->Auth->fields = array('username' => 'emailid', 'password' 
=>
'password');
                $this->Auth->loginAction = array('controller' => 
'Userinformations',
'action' => 'login');
                $this->Auth->loginRedirect = array('controller' =>
'Userinformations', 'action' => 'updateuserprofile');
                //sign up  is a page which don't requires to login
                $this->Auth->allow('signup');
                $this->Auth->authorize = 'controller';
                $this->Auth->logoutRedirect = '/';

        }
            function isAuthorized() {

        return true;

    }

}

Model -> userinformation

class Userinformation extends Appmodel
{
        var $name='Userinformation';
        var $primaryKey = 'userid';

        .
        .
        .
        .
        .
        .
        .
function hashPasswords($data){
if(isset($this->data['Userinformation']['password'])){
        $this->data['Userinformation']['password']= md5($this-
>data['Userinformation']['password']);
        return $data;
}
return $data;
}
function beforeSave() {
$this->hashPasswords(NULL,TRUE);
return TRUE;
}
}

Controller - > UserinformationsController

        function login(){

        }
        function logout() {
                $this->redirect($this->Auth->logout());
        }

view -> userinformations/login.ctp

<?php

echo $this->Session->flash('auth');
echo $form->create('userinformation', array('action' => 'login'));
echo $form->input('user.username');
echo $form->input('user.password');
echo $form->end('Login');

?>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to