Re: Help with function Login()--using Auth (Redirecting issue)
On Tue, Dec 28, 2010 at 11:58 PM, John Maxim goog...@gmail.com wrote: Users_controllers.php: var $name = 'Users'; /*some codes in between*/ function login() { if(!empty($this-data)) { // If the username/password match if($this-Auth-login($this-data)) { $this-redirect(array('action' = 'index'), null, true); } else { $this-User-invalidate('username', 'Username and password combination is incorrect!'); } } } The code in your login method does basically what Auth would do if left to its own devices. You could get the same functionality as above by setting the following in AppController's beforeFilter method: // this tells Auth to handle redirects $this-Auth-autoRedirect = true; // this tells Auth where to send the user $this-Auth-loginRedirect = array( 'controller' = 'posts', 'action' = 'index' ); $this-Auth-loginError = 'Username and password combination is incorrect!'; if (!$this-Session-read('Auth.User')) { $this-Auth-authError = 'Please log in'; } You set the first one to false when you need to do some routines during login--like record the login time, set a session var, etc. Otherwise, you can leave login() empty and allow Auth to sort it all out. 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Help with function Login()--using Auth (Redirecting issue)
Hi, By default, Auth component redirects to referrer page (if set) otherwise to the page set in loginRedirect. So you may need to overwrite 'Auth.redirect' session parameter. FYI, please have a look at http://book.cakephp.org/view/1270/loginRedirect Amit Badkas PHP Applications for E-Biz: http://www.sanisoft.com On Thu, Dec 30, 2010 at 12:29 AM, cricket zijn.digi...@gmail.com wrote: On Tue, Dec 28, 2010 at 11:58 PM, John Maxim goog...@gmail.com wrote: Users_controllers.php: var $name = 'Users'; /*some codes in between*/ function login() { if(!empty($this-data)) { // If the username/password match if($this-Auth-login($this-data)) { $this-redirect(array('action' = 'index'), null, true); } else { $this-User-invalidate('username', 'Username and password combination is incorrect!'); } } } The code in your login method does basically what Auth would do if left to its own devices. You could get the same functionality as above by setting the following in AppController's beforeFilter method: // this tells Auth to handle redirects $this-Auth-autoRedirect = true; // this tells Auth where to send the user $this-Auth-loginRedirect = array( 'controller' = 'posts', 'action' = 'index' ); $this-Auth-loginError = 'Username and password combination is incorrect!'; if (!$this-Session-read('Auth.User')) { $this-Auth-authError = 'Please log in'; } You set the first one to false when you need to do some routines during login--like record the login time, set a session var, etc. Otherwise, you can leave login() empty and allow Auth to sort it all out. 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+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Help with function Login()--using Auth (Redirecting issue)
Hi cricket ! you're awesome, thanks your working and explanation solved the puzzle I had.. Amit, I will check that link out..thanks too. Regards, Maxim On Dec 30, 12:54 pm, Amit Badkas amit.sanis...@gmail.com wrote: Hi, By default, Auth component redirects to referrer page (if set) otherwise to the page set in loginRedirect. So you may need to overwrite 'Auth.redirect' session parameter. FYI, please have a look athttp://book.cakephp.org/view/1270/loginRedirect Amit Badkas PHP Applications for E-Biz:http://www.sanisoft.com On Thu, Dec 30, 2010 at 12:29 AM, cricket zijn.digi...@gmail.com wrote: On Tue, Dec 28, 2010 at 11:58 PM, John Maxim goog...@gmail.com wrote: Users_controllers.php: var $name = 'Users'; /*some codes in between*/ function login() { if(!empty($this-data)) { // If the username/password match if($this-Auth-login($this-data)) { $this-redirect(array('action' = 'index'), null, true); } else { $this-User-invalidate('username', 'Username and password combination is incorrect!'); } } } The code in your login method does basically what Auth would do if left to its own devices. You could get the same functionality as above by setting the following in AppController's beforeFilter method: // this tells Auth to handle redirects $this-Auth-autoRedirect = true; // this tells Auth where to send the user $this-Auth-loginRedirect = array( 'controller' = 'posts', 'action' = 'index' ); $this-Auth-loginError = 'Username and password combination is incorrect!'; if (!$this-Session-read('Auth.User')) { $this-Auth-authError = 'Please log in'; } You set the first one to false when you need to do some routines during login--like record the login time, set a session var, etc. Otherwise, you can leave login() empty and allow Auth to sort it all out. Check out the new CakePHP Questions sitehttp://cakeqs.organd 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+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Help with function Login()--using Auth (Redirecting issue)
Hi, In CakePHP, the views don't display directly, you need to render them using actions of controllers. From your description, it seems that you need to redirect to /posts/index page, so use $this-redirect(array('controller' = 'posts', 'action' = 'index')); to go to that page. Hope this helps. Amit Badkas PHP Applications for E-Biz: http://www.sanisoft.com On Wed, Dec 29, 2010 at 10:28 AM, John Maxim goog...@gmail.com wrote: Users_controllers.php: var $name = 'Users'; /*some codes in between*/ function login() { if(!empty($this-data)) { // If the username/password match if($this-Auth-login($this-data)) { $this-redirect(array('action' = 'index'), null, true); } else { $this-User-invalidate('username', 'Username and password combination is incorrect!'); } } } - Hi, After successful login, I want it to redirect to app/views/posts/ index.ctp Originally, the redirect code is like this: (1) ~~ $this-redirect('/'); ~~ I changed to: (2) ~~ $this-redirect(array('action' = 'index'), null, true); ~~ (3) ~~ $this-redirect(array('action' = 'views/posts/index'), null, true); ~~ All failed to redirect to *app/views/posts/index.ctp ~~ It consistently redirected me to my App/index.ctp which displays all my cakephp versions stuff (mod rewrite...etc the green page), regardless of the 3 redirect methods used above. Is it something wrong with my Login() function instead ?? Thanks, Maxim J. 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+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Help with function Login()--using Auth (Redirecting issue)
Hi Amit, I used your code: $this-redirect(array('controller' = 'posts', 'action' = 'index')); but it still redirects me to the root directory... What can be wrong ? On Dec 29, 1:39 pm, Amit Badkas amit.sanis...@gmail.com wrote: Hi, In CakePHP, the views don't display directly, you need to render them using actions of controllers. From your description, it seems that you need to redirect to /posts/index page, so use $this-redirect(array('controller' = 'posts', 'action' = 'index')); to go to that page. Hope this helps. Amit Badkas PHP Applications for E-Biz:http://www.sanisoft.com On Wed, Dec 29, 2010 at 10:28 AM, John Maxim goog...@gmail.com wrote: Users_controllers.php: var $name = 'Users'; /*some codes in between*/ function login() { if(!empty($this-data)) { // If the username/password match if($this-Auth-login($this-data)) { $this-redirect(array('action' = 'index'), null, true); } else { $this-User-invalidate('username', 'Username and password combination is incorrect!'); } } } - Hi, After successful login, I want it to redirect to app/views/posts/ index.ctp Originally, the redirect code is like this: (1) ~~ $this-redirect('/'); ~~ I changed to: (2) ~~ $this-redirect(array('action' = 'index'), null, true); ~~ (3) ~~ $this-redirect(array('action' = 'views/posts/index'), null, true); ~~ All failed to redirect to *app/views/posts/index.ctp ~~ It consistently redirected me to my App/index.ctp which displays all my cakephp versions stuff (mod rewrite...etc the green page), regardless of the 3 redirect methods used above. Is it something wrong with my Login() function instead ?? Thanks, Maxim J. Check out the new CakePHP Questions sitehttp://cakeqs.organd 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+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Help with function Login()--using Auth (Redirecting issue)
Hi, I think the problem is due to other thing(s). I can't advise much without looking at all of the code. However, please refer http://book.cakephp.org/view/1250/Authentication to check if you have set-up authentication parameters correctly or not. Hope this helps. Amit Badkas PHP Applications for E-Biz: http://www.sanisoft.com On Wed, Dec 29, 2010 at 11:49 AM, John Maxim goog...@gmail.com wrote: Hi Amit, I used your code: $this-redirect(array('controller' = 'posts', 'action' = 'index')); but it still redirects me to the root directory... What can be wrong ? On Dec 29, 1:39 pm, Amit Badkas amit.sanis...@gmail.com wrote: Hi, In CakePHP, the views don't display directly, you need to render them using actions of controllers. From your description, it seems that you need to redirect to /posts/index page, so use $this-redirect(array('controller' = 'posts', 'action' = 'index')); to go to that page. Hope this helps. Amit Badkas PHP Applications for E-Biz:http://www.sanisoft.com On Wed, Dec 29, 2010 at 10:28 AM, John Maxim goog...@gmail.com wrote: Users_controllers.php: var $name = 'Users'; /*some codes in between*/ function login() { if(!empty($this-data)) { // If the username/password match if($this-Auth-login($this-data)) { $this-redirect(array('action' = 'index'), null, true); } else { $this-User-invalidate('username', 'Username and password combination is incorrect!'); } } } - Hi, After successful login, I want it to redirect to app/views/posts/ index.ctp Originally, the redirect code is like this: (1) ~~ $this-redirect('/'); ~~ I changed to: (2) ~~ $this-redirect(array('action' = 'index'), null, true); ~~ (3) ~~ $this-redirect(array('action' = 'views/posts/index'), null, true); ~~ All failed to redirect to *app/views/posts/index.ctp ~~ It consistently redirected me to my App/index.ctp which displays all my cakephp versions stuff (mod rewrite...etc the green page), regardless of the 3 redirect methods used above. Is it something wrong with my Login() function instead ?? Thanks, Maxim J. Check out the new CakePHP Questions sitehttp://cakeqs.organd 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+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.com cake-php%2bunsubscr...@googlegroups.comcake-php%252bunsubscr...@googlegroups.comFor 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+unsubscr...@googlegroups.comcake-php%2bunsubscr...@googlegroups.comFor 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en