Thank you so much. It worked :)
On Thu, Apr 1, 2010 at 5:30 PM, anl hp <anler86@gmail.com> wrote:
The Auth component set the session automatically so if not working something else is going wrong. Try this:
in the before filter method:
$this->Auth->autoRedirect = false
and then in login method
if ( $this->Auth->user() )
debug ( $this->Session->read( 'Auth' ); exit;
and check the session data and the sql log to see if authentication succeed correctly
--
anl
On Thu, Apr 1, 2010 at 7:25 PM, mdb <meena.doss@gmail.com> wrote:Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.Hi,
I'm using cakephp 1.3 and very new to php. I have a basic
Authentication Screen and it works well.
The problem i have is when i login, depending on the roleid of the
user, it should be redirected to different page, which i donno how .
Example
User Table
UserId int pk
username varchar
password varchar
roleid int
Users_Controller
<?php
class UsersController extends AppController
{
var $name = 'Users';
var $components = array('Auth');
function beforeFilter()
{
parent::beforeFilter();
$this->Auth->loginRedirect = array('controller' => 'Users',
'action' => 'index');
}
function index()
{
$this->set('users', $this->User->find('all'));
}
function login()
{
}
function logout()
{
$this->redirect($this->Auth->logout());
}
}
?>
User Model
<?php
class User extends AppModel
{
var $primaryKey = 'UserID';
var $validate = array('username' => array('rule' =>
'notEmpty','message'=> 'Empty'));}
?>
View
<div class="user">
<?php
$session->flash('');
$session->flash('auth'); ?>
<?php echo $form->create('User', array('action' => 'login'));?>
<table width="100%" cellpadding="5" cellspacing="5">
<tr>
<td align="center">
<table width="30%" cellpadding="5" cellspacing="15">
<tr>
<td class="label1">
User Name:
</td>
<td>
<?php echo $form-
>input('username',array('label'=>false));?>
</td>
</tr>
<tr>
<td class="label1">
Password:
</td>
<td class="label1">
<?php echo $form-
>input('password',array('label'=>false));?>
</td>
</tr>
<tr>
<td colspan="2" class="button">
<center><?php echo $form->end('Sign In');?></
center>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
Now, if the user role is admin I need to redirect to Events, if Member
redirect to Home........
Also how do I store the authenticated user in the Session. Its not
happening.
Thanks
MDB
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
To unsubscribe, reply using "remove me" as the subject.
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment