Re: Changing the Auth-loginRedirect based on value in user model

2011-01-07 Thread eldorado2768
Have you figured out how to get it to work? I am doing essentially the same 
thing and my error is identical to yours. I am looking at the group_id the 
user belongs to and then redirect based on which id. 




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 cake-php@googlegroups.com
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?hl=en


Changing the Auth-loginRedirect based on value in user model

2008-11-05 Thread [EMAIL PROTECTED]

Hi all,

I have a simple app that needs to have 2 types of users, normal users
and admins. I have got the Auth component working great and has the
entire site requiring log in etc, but I want to redirect users that
are admins to the admin route sections upon login.

I have this in my app_controller:

function beforeFilter() {
$this-Auth-allow('display');
$this-Auth-logoutRedirect =
array(Configure::read('Routing.admin') = false, 'controller' =
'users', 'action' = 'logout');
$user = $this-Auth-user();
//debug($user);
if($user['User']['admin'] == 'n') {
$this-Auth-loginRedirect = array('controller'='orders',
'action'='index');
} else {
$this-Auth-loginRedirect = array('controller'='orders',
'action'='index', 'admin' = true);
}

}

And while it doesnt throw errors it seems to behave wierdly - it
redirects to the /admin route regardless, but if I go back in my
browser and login again it redirects to the correct page!

Has anyone tried to do this before? Any suggestions what I may be
missing?
TIA,
d.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP 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?hl=en
-~--~~~~--~~--~--~---



Re: Changing the Auth-loginRedirect based on value in user model

2008-11-05 Thread francky06l

Well quite normal since as long as you are not logged in beforeFilter
has no much effect on redirection ..
Better, use $this-Auth-autoRedirect = false; in beforeFilter ..

In login,

if($this-Auth-user('id'))
{
if($this-Auth-user('admin') == 'n')
blah;
else
otherblah ...
}

hth

On Nov 5, 4:03 pm, [EMAIL PROTECTED] [EMAIL PROTECTED]
wrote:
 Hi all,

 I have a simple app that needs to have 2 types of users, normal users
 and admins. I have got the Auth component working great and has the
 entire site requiring log in etc, but I want to redirect users that
 are admins to the admin route sections upon login.

 I have this in my app_controller:

 function beforeFilter() {
 $this-Auth-allow('display');
 $this-Auth-logoutRedirect =
 array(Configure::read('Routing.admin') = false, 'controller' =
 'users', 'action' = 'logout');
 $user = $this-Auth-user();
 //debug($user);
 if($user['User']['admin'] == 'n') {
 $this-Auth-loginRedirect = array('controller'='orders',
 'action'='index');
 } else {
 $this-Auth-loginRedirect = array('controller'='orders',
 'action'='index', 'admin' = true);
 }

 }

 And while it doesnt throw errors it seems to behave wierdly - it
 redirects to the /admin route regardless, but if I go back in my
 browser and login again it redirects to the correct page!

 Has anyone tried to do this before? Any suggestions what I may be
 missing?
 TIA,
 d.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP 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?hl=en
-~--~~~~--~~--~--~---