In your header element
$loggedIn = $this->Session->read('Auth.User.id');
if (!$loggedIn) {
// login form }
} else {
// control panel
}
Your User info is all in the session so no need to go grab it again.
K
-----Original Message-----
From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf
Of Trader5050
Sent: Friday, April 01, 2011 2:29 PM
To: CakePHP
Subject: Problem calling private method
Hello,
I have a header element that I want to display either a login form or
a control panel depending on whether or not the user is logged in.
... in my header element: ...
$user = $this->requestAction('users/getUser');
if (empty($user)) { // login form }
else { // control panel }
...and in my controller...
function _getUser() {
if ($this->Session->read('Auth.User')) { return $this->Auth-
>user(); }
else { return false; }
}
The problem is that I don't want someone to be able to type /users/
getUser. Therefore, I tried making it private (_getUser). When I do
so, I get a nested error in which the entire header is repeating
itself infinitely. I have no idea why.
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help
others with their CakePHP related questions.
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
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
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
No comments:
Post a Comment