Hi !
Im new to cake but have quickly became found of it and are now
building a site that requires auth. othAuth seems like a great
component and have played around with it but can't get it working
completely as I would like. I have searched for an answer but without
luck so here are my two questions:
1. After commiting a logut I am still able to return to the restricted
area by hitting the back button.
2. In firefox, if i choce not to log out I can reach the restricted
area again without needing to login after restarting firefox. I have
tried messing with othAuths cookie variables but without any luck.
I would appriciate any help I could get, here are some example code
snippets I am using:
view: login.thtml
<h1>Log In:</h1>
<?php
if (! empty($errorMessage))
echo $errorMessage;
?>
<form action="<?php echo $html->url('/users/login')?>" method="post">
<p>
Username:
<?php echo $html->input('User/username', array('size' => '40'))?>
<?php echo $html->tagErrorMsg('User/username', 'Please enter your
username') ?>
</p>
<p>
Password:
<?php echo $html->input('User/passwd', array('id' => 'user_passwd',
'size' => '40', 'type'=>"password")) ?>
<?php echo $html->tagErrorMsg('User/passwd', 'Please enter your
password!') ?>
</p>
<?php echo $html->checkbox("User/cookie");?>
<p>
<?php echo $html->submit('Login')?>
</p>
</form>
controller: users_controller.php
<?php
class UsersController extends AppController {
var $name = 'Users';
function index() {
}
function home() {
}
function add() {
if(!empty($this->data)) {
if ($this->User->create($this->data) &&
$this->User->validates()) {
$this->set('valid', true);
}
}
}
function login() {
if(isset($this->data['User'])) {
$auth_num = $this->othAuth->login($this-
>data['User']);
$this->set('errorMessage', $this->othAuth->getMsg($auth_num));
$this->render();
}
}
function logout()
{
$this->othAuth->logout();
if ($this -> Session -> valid()) {
$this -> Session -> destroy();
$this -> redirect('/users/login');
}
//$this->flash('You are now logged out!','/users/login');
}
function noaccess()
{
$this->flash("You don't have permissions to access this page.",'/
users/login');
}
}
?>
And the before method:
function beforeFilter()
{
$auth_conf = array(
'mode' => 'oth',
'login_page' => '/users/login',
'logout_page' => '/users/logout',
'access_page' => '/users/index',
'hashkey' => 'MySEcEeTHaSHKeYz',
'noaccess_page' => '/users/noaccess',
'cookie_active' => true,
'cookie_lifetime' => '-1 day',
// 'kill_old_login' => true,'
// 'gid' => 3,
'strict_gid_check' => false);
$this->othAuth->controller = &$this;
$this->othAuth->init($auth_conf);
$this->othAuth->check();
}
Thanx!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---