beforeFilter bug?

2006-06-26 Thread carlosrg

Hi,

I'm trying to add a little user authentification to my product
controller.

My code is:

class ProductsController extends AppController
{
var $protectedActions = array('add', 'edit', 'delete');

function beforeFilter(){
if (in_array($this-action, $this-protectedActions))
{
$this-checkSession();
}
}
...
function delete($id)
{
$this-Product-del($id);
$this-redirect('/products/index');
}
...

In 'add' and 'edit' actions, if I'm not logged I am redirected to
loginController, but with 'delete' action I am not redirected to, and
the product is deleted. I don't know where is the problem.

Thanks a lot!


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: beforeFilter bug?

2006-06-26 Thread AD7six

Hi Carlosrg,

I would suggest putting

else
{
pr ($this-action); die;
}

In your before filter and calling the delete method, seeing what it
says and go from there.

Cheers,

AD7six


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: beforeFilter bug?

2006-06-26 Thread AD7six

Hi Carlosrg,

Your post indicates that the checkSession method is run for a delete
call.

What does checkSession do?
*If it does not contain a die statement your code will continue to
run.
*If checkSession returns a value, it is not passed to beforeFilter
*If beforeFilter does not return False, the controller method is still
run


You can fix this by either
1) coding checkSession to die after redirecting.
2) coding checkSession to return false if it fails AND coding
beforeFilter to return the result of checkSession

Si hay algo mas, y preferias escribir EspaƱol - ir a CakeES :)

Cheers,

AD7six


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---