Thanks for the response, Amit. However, the login isn't only for
admins. But, when trying to do something using an admin route, i'm
seeing this problem.
On Sat, May 10, 2008 at 5:28 AM, Amit Badkas <[EMAIL PROTECTED]> wrote:
> On Sat, May 10, 2008 at 12:06 AM, b logica <[EMAIL PROTECTED]> wrote:
>>
>> I've got the dead simplest login setup here but it's consistently
>> failing and I'm out of ideas for debugging this. I have admin routing
>> enabled and am trying to , no surprise, log in as an admin.
>>
>>
>> db_dam=# select * from users where model = 'Admin';
>> id | enabled | model | foreign_key | email |
>> password | last_login
>>
>> ----+---------+-------+-------------+------------------------+------------------------------------------+------------
>> 1 | t | Admin | 1 | [EMAIL PROTECTED] |
>> b45c0cb88fd7f6cf4136554605f08ece73297664 |
>> (1 row)
>>
>> I got the password by doing:
>>
>> debug($this->Auth->password(array('User' => array('password' =>
>> 'foobar'))));
>>
>> admin_login.ctp
>> <?= $form->create('User', array('action' => 'admin_login')) ?>
>> <?= $form->input('User.email') ?>
>> <?= $form->input('User.password') ?>
>> <?= $form->submit('Login') ?>
>> <?= $form->end() ?>
>>
>> UsersController:
>>
>> function admin_login()
>> {
>> if (!empty($this->data))
>> {
>> if ($this->Auth->login())
>> {
>> $this->redirect($this->Auth->redirect());
>> }
>> else
>> {
>> $this->Session->setFlash($this->Auth->authError);
>> }
>> }
>> }
>>
>> AppController:
>>
>> function beforeFilter()
>> {
>> $this->Auth->fields = array('username' => 'email', 'password' =>
>> 'password');
>> $this->Auth->authorize = 'controller';
>> $this->Auth->loginAction = array('controller' => 'users', 'action'
>> => 'login');
>
> - Change above to $this->Auth->loginAction = array('admin' => true,
> 'controller' => 'users', 'action' => 'login');
>
>> $this->Auth->loginRedirect = array('controller' => 'users',
>> 'action'
>> => 'index');
>> $this->Auth->logoutRedirect = '/';
>> $this->Auth->autoRedirect = false;
>> $this->Auth->allow('setLang', 'enableComponent', 'enableElement',
>> 'disableElement', 'flash');
>> }
>>
>> //(temporarily)
>>
>> function isAuthorized()
>> {
>> return true;
>> }
>>
>> I thought that $this->Auth->loginAction, being set to login() and not
>> admin_login() was causing the problem.But a log() statement in the
>> former shows nothing so it doesn't seem to be redirecting there
>> instead.
>>
>> What am i missing here?
>>
>>
>
>
>
> --
> Regards,
> Amit
>
> http://amitrb.wordpress.com/
> http://coppermine-gallery.net/
> http://cheesecake-photoblog.org/
> http://www.sanisoft.com/blog/author/amitbadkas
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---