Hello, I am trying to check out different php frameworks. As a first test I want to create a login box that should appear on every page of the website (that has the standard layout). If a user is not logged in, the login form should appear. If he is logged in, an appropriate message and a logout link or button should appear.
I baked the Users model and controller, that worked fine. The I created an element "loginbox" that I refer to in my default.ctp by "echo $this->element('loginbox');". For a start, loginbox.ctp simply created a login form. The password field in the database table is hashed with md5, so in the app_controller.php's beforeFIlter I execute "Security::setHash ('md5');". I work on the very same database and table with a similar Zend test project, and login works fine there. But in CakePHP I have problems. First: I am not logged in. Instead I land on a page with a login box in the main content area (plus of course the login box that I constructed myself as an element). In the users_controller.php's beforeFilter I placed: $this->Auth->loginError = 'Invalid e-mail / password combination. Please try again'; But this error appears nowhere (although I places "$session->flash ('auth');" in loginbox.ctp) For testing purposes I places "$this->Auth->autoRedirect = false;" in the users_controller.php's beforeFilter and then placed code in the login function of that controller (from here: http://www.littlehart.net/atthekeyboard/2007/09/11/a-hopefully-useful-tutorial-for-using-cakephps-auth-component/) I modified that code a little to redirect to http://www.yahoo.de when the login failed. That worked. So at least I think that the controller is used at all. But then the question is: Why does the login not work? I modified the security's hashing algorithm to MD5, so it should work. The other question is: how could I access the Auth component from a layout or an element? The loginbox.ctp should only show the login form if the user is not logged in. So I need an conditional clause in the loginbox.ctp and need to determine whether the user is logged in or not. Or alternatively I need a loginbox.ctp and a logoutbox.ctp and then in the default.ctp I place an conditional clause that either places the loginbox or the logoutbox in the header section. A third question: As I mentioned above, if I keep the autoRedirect switched on and the login fails, a login form is displayed in the main area. Though this can be a wanted behavior for some websites, just out of curiosity: How would it be done to keep the user on the actual page and let the loginbox handle the display of the error? I found this as a description of how to store the referrer into a session (http:// bin.cakephp.org/view/316159681). But then how would I tell the users_controller.php to jump to the actual page in case of a failed login attempt? Does it have to be done by switching of autoRedirect and doing it by myself in the login function? Any help or a hint would be very appreciated. Christian --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---