I included this built-in in my controller:
var $components = array('Auth');
so now my controller looks like this:
class UsersController extends AppController
{
var $name = 'Users';
var $helpers = array('Html', 'Form' );
var $components = array('Auth');
function register()
{
if (!empty($this->data))
{
if ($this->User->save($this->data))
{
$this->Session->setFlash('Your registration
information was
accepted.');
}
}
}
function knownusers()
{
$this->set('knownusers',
$this->User->find('all', array('order' => array('User.id
DESC')),
array('fields' => array('User.id', 'User.username', 'User.first_name',
'User.last_name')))
);
}
function login()
{
}
function logout() {
$this->redirect($this->Auth->logout());
}
}
***************
I can't view my register and knownusers page now, it redirects me to
login page.
My login page is as follow:
<?php
echo $session->flash('auth');
echo $this->Form->create('User', array('action' => 'login'));
echo $this->Form->input('username');
echo $this->Form->input('password');
echo $this->Form->end('Login');
?>
Why is it redirected each time I view register and knownusers
page ...to login page ?
How do I know if the hash password is already working now ?? since I
can't register ..?
On Dec 20, 11:25 am, John Maxim <[email protected]> wrote:
> My controller is here:
>
> class UsersController extends AppController
> {
>
> var $name = 'Users';
>
> var $helpers = array('Html', 'Form' );
>
> function register()
> {
> if (!empty($this->data))
> {
> if ($this->User->save($this->data))
> {
> $this->Session->setFlash('Your registration
> information was
> accepted.');
> }
> }
> }
>
> Do I add this in?:
>
> var $components = array('Auth');
>
> or can I add into var $helpers = array('Html', 'Form',
> 'Auth' ); ?
>
> Sorry my password validation is here:
>
> 'password' => array(
> 'notEmpty' => array(
> 'rule' => 'notEmpty',
> 'message' => 'This field cannot be blank.',
> 'last' => true,
> ),
>
> ***
>
> and no, I didn't get any error, the only problem was the validation
> for password can't be triggered after I used the code I posted from
> the first post (NEW). After editing back to my (OLD) code it works
> fine now except with no HASHING and AUTO-LOGIN feature.
>
> Can you point me to AUTO-LOGIN coding ? how should I go about? I'm
> still not done with hashing yet, as I'm not sure how to use AUTH
> component.
>
> On Dec 20, 3:10 am, cricket <[email protected]> wrote:
>
> > On Sun, Dec 19, 2010 at 2:07 AM, John Maxim <[email protected]> wrote:
> > > What are Auth component ?
>
> >http://book.cakephp.org/view/1250/Authentication
>
> > Just note that Auth will hash your password for you, so there's no
> > need to cal md5().
>
> > > My validation rules are here:
>
> > There's no password validation there. What, exactly, is the problem
> > you're seeing? Could you post the validation rules?
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en