I've been piecing this together from random ideas and tutorials I have found online.
First off, I am not trying to build a complicatedly secure system, and this login function i have going is working.
But what I cannot resolve is:
1) How do I redirect the users to my views/cms/index once the user has logged in? In my index controller function I tried:
$this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'cms'); - but this did absolutely nothing.
2) Further, login.ctp (see below) I tried to display my logout button like so:
<?php if(isset($Auth)) {echo $html->link('Logout',array('controller'=>'users','action'=>'logout')); } ?> - and this did not work either?
I removed all of the "non-working" code from my below code. But you can see what I've got going.
I would appreciate any comments, advice, or corrections here cause I just can't get this to come together the way I need it to.
######################################################
users_controller.php
######################################################
<?php
class UsersController extends AppController {
var $name = 'Users';
function login() {
}
function logout() {
$this->redirect($this->Auth->logout());
$this->Session->destroy('user');
$this->redirect('login');
}
}
?>
######################################################
user.php - model
######################################################
<?php
class User extends AppModel {
var $name = 'User';
}
?>
######################################################
login.ctp - view
######################################################
<?php
if ($session->check('Message.auth')) $session->flash('auth');
echo $form->create('User', array('action' => 'login'));
echo $form->input('username');
echo $form->input('password');
echo $form->end('Login');
}
?>
--
View this message in context: http://n2.nabble.com/Simple-Auth-Login-System-%28Code-Included%29----Need-Tips-tp2547075p2547075.html
Sent from the CakePHP mailing list archive at Nabble.com.
--~--~---------~--~----~------------~-------~--~----~
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