Login Redirects
Hi.. I have currently set autoRedirect to false in app_controller ($this- >Auth->autoRedirect = false;).. and made a redirection upon logging in.. here the codes for login function: Function login() { if ($this->Session->read('Auth.User')) { $this->Session->setFlash('You are logged in!'); $this->redirect('/announcements/home', null, false); } } When the user logs in, it redirects to announcements/home instead of the last page where he was when he last logged out.. the problem is, that the page doesn't seem to update and would still seem like the user has not logged in until the user refresh the page. the controlpanel will not appear as it supposed to. how can i solve this problem? been stuck in this situation for more than 5 hours now. :( Thanks. 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: user authentication example...login redirects
var $validate = array( 'name' => array( 'rule' => array('custom', VALID_NOT_EMPTY), 'message' => 'Can\'t be empty' ) ); This is how i deal with not empty values. VALID_NOT_EMPTY may be deprecated, but still it's just a constat so i can replace it with whatever regexp i want. AFAIK 'allowEmpty' is false by default and it's checked before rule description, and if u dont specify rule key in field validation array it will default to 'blank'. In your example Zoe field name will always invalidate because it can't be empty, thanks to 'allowEmpty', but rule defaulted to 'blank' expecting it to be empty. On 9. Feb, 09:36 h., MonkeyGirl <[EMAIL PROTECTED]> wrote: > > The 'allowEmpty' key should be assigned a boolean value. > > Ah, thank you. That makes sense. So I've replaced this: > > var $validate = array( > 'name' => array( > 'required' => VALID_NOT_EMPTY > ) > ); > > With this now: > > var $validate = array( > 'name' => array( > array( > 'message' => 'required', > 'allowEmpty' => FALSE > ) > ) > ); > > Is that right? (I know it technically works, I just want to make sure > I'm doing it the "proper" way). > > Thank you, > Zoe. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: user authentication example...login redirects
> The 'allowEmpty' key should be assigned a boolean value. Ah, thank you. That makes sense. So I've replaced this: var $validate = array( 'name' => array( 'required' => VALID_NOT_EMPTY ) ); With this now: var $validate = array( 'name' => array( array( 'message' => 'required', 'allowEmpty' => FALSE ) ) ); Is that right? (I know it technically works, I just want to make sure I'm doing it the "proper" way). Thank you, Zoe. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: user authentication example...login redirects
in 1.2, it is required to be set in a string, or you could use the following validation rule: "allowEmpty The 'allowEmpty' key should be assigned a boolean value. If ' allowEmpty' is false, data passed to the model's save() method must include the field and a non-empty data value for that field. This rule is only enforced when the field index is present in the supplied data array. The default value of 'allowEmpty' is false." On Feb 8, 2008 7:32 AM, MonkeyGirl <[EMAIL PROTECTED]> wrote: > > > also, in regards to the second error, make sure in your model->validate > > array, that you have apostrophes around the words 'VALID_NOT_EMPTY', > which > > should clear out that error. > > Will it? I thought VALID_NOT_EMPTY *was* a constant, not a literal > string. > > I've also heard on someone's blog that it's now depreciated, but with > no clue as to what by. I know there's a bunch of new validation types > such as credit card in the new system, but I can't seem to find "not > empty" anymore. Is this depreciated or not? > > Thanks, > Zoe. > > > -- In the name of Life, Liberty, and the pursuit of my sanity. Siebren Bakker(Aevum Decessus) -BEGIN GEEK CODE BLOCK- Version: 3.12 GCS d- s+: a19 C UL++ P L++ !E W++ N(-) o? K? w(+) O? M-- V? PS+ PE Y- PGP- t+ 5? X- R tv-- b++ Di D+ G+ e h! r y- --END GEEK CODE BLOCK-- --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: user authentication example...login redirects
> also, in regards to the second error, make sure in your model->validate > array, that you have apostrophes around the words 'VALID_NOT_EMPTY', which > should clear out that error. Will it? I thought VALID_NOT_EMPTY *was* a constant, not a literal string. I've also heard on someone's blog that it's now depreciated, but with no clue as to what by. I know there's a bunch of new validation types such as credit card in the new system, but I can't seem to find "not empty" anymore. Is this depreciated or not? Thanks, Zoe. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: user authentication example...login redirects
also, in regards to the second error, make sure in your model->validate array, that you have apostrophes around the words 'VALID_NOT_EMPTY', which should clear out that error. On Feb 8, 2008 7:15 AM, MonkeyGirl <[EMAIL PROTECTED]> wrote: > > > The code i have creates my user and puts it into the database just > > fine..but after that, nothing happens... no flash, no redirect. > > Have you made a login() function in /app/controllers/ > users_controller.php? It looks like you've got the creation of new > users sorted, but you now need to let them log in, which is really a > separate process. You need to get the login method working next, then > you can worry about making it happen automatically once someone's > signed up. > > This is something I want to explain in my guide soon, but for now try > looking into $this->Session in the controller. That's what you can use > to store the information about the user who's logging in, so it > remembers them as they move around the site. > > Hope that helps, > Zoe. > > > -- In the name of Life, Liberty, and the pursuit of my sanity. Siebren Bakker(Aevum Decessus) -BEGIN GEEK CODE BLOCK- Version: 3.12 GCS d- s+: a19 C UL++ P L++ !E W++ N(-) o? K? w(+) O? M-- V? PS+ PE Y- PGP- t+ 5? X- R tv-- b++ Di D+ G+ e h! r y- --END GEEK CODE BLOCK-- --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: user authentication example...login redirects
> The code i have creates my user and puts it into the database just > fine..but after that, nothing happens... no flash, no redirect. Have you made a login() function in /app/controllers/ users_controller.php? It looks like you've got the creation of new users sorted, but you now need to let them log in, which is really a separate process. You need to get the login method working next, then you can worry about making it happen automatically once someone's signed up. This is something I want to explain in my guide soon, but for now try looking into $this->Session in the controller. That's what you can use to store the information about the user who's logging in, so it remembers them as they move around the site. Hope that helps, Zoe. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: user authentication example...login redirects
>From the first Error message It looks your Cache directory is not writable. and The third message regarding Cannot modify header information.. I Use Writing ob_start(); just next line to PHP start tags before starting my controller class and ob_clean(); just before my php end tags and after the end of my controller class. It is PHP way, but it worked for me in Cake too. Hope this helps. On Feb 8, 9:36 am, polomasta <[EMAIL PROTECTED]> wrote: > no luck yet, I tried this as well: > > $this->redirect(array('controller'=>'users','action'=>'login')); > > I'm also getting these things in the debug area... > > Warning (512): /var/www/html/bradsCakeApp/app/tmp/cache/ is not > writable [CORE/cake/libs/cache/file.php, line 263] > > Notice (8): Use of undefined constant VALID_NOT_EMPTY - assumed > 'VALID_NOT_EMPTY' [CORE/cake/dispatcher.php, line 508] > > Warning (2): Cannot modify header information - headers already sent > by (output started at /var/www/html/bradsCakeApp/cake/basics.php:194) > [CORE/cake/libs/controller/controller.php, line 546] > > I've double checked all my files for extra whitespace at the end of > files and can't find anything. I'm not sure what else to try. Really > appreciate any additional help. > > _brad --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: user authentication example...login redirects
no luck yet, I tried this as well: $this->redirect(array('controller'=>'users','action'=>'login')); I'm also getting these things in the debug area... Warning (512): /var/www/html/bradsCakeApp/app/tmp/cache/ is not writable [CORE/cake/libs/cache/file.php, line 263] Notice (8): Use of undefined constant VALID_NOT_EMPTY - assumed 'VALID_NOT_EMPTY' [CORE/cake/dispatcher.php, line 508] Warning (2): Cannot modify header information - headers already sent by (output started at /var/www/html/bradsCakeApp/cake/basics.php:194) [CORE/cake/libs/controller/controller.php, line 546] I've double checked all my files for extra whitespace at the end of files and can't find anything. I'm not sure what else to try. Really appreciate any additional help. _brad --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: user authentication example...login redirects
try using the full path in the login redirect, i.e. $this->redirect('/users/login'); you also should add the 'true' tag, if you are using CakePHP1.2, to automatically call the exit() function after the redirect. i.e. $this->redirect('/users/login', true); Hope this helps! On Feb 7, 2008 5:43 PM, polomasta <[EMAIL PROTECTED]> wrote: > > i've been trying to implement that scattered examples of user > registration/authentication systems and without much success. I know > it's due to my lack of sKiLLz or whatever, but I could use some help. > > The code i have creates my user and puts it into the database just > fine..but after that, nothing happens... no flash, no redirect. I > can't figure it out. here is my register code in the users_controller: > > function register() { >if (!empty($this->data)) { >if ($this->data['User']['password'] == $this->Auth- > >password($this->data['User']['password_confirm'])) { >$this->User->create(); >$this->User->save($this->data); >$this->redirect('login'); >} >} >} > > what am I doing wrong? > > > -- In the name of Life, Liberty, and the pursuit of my sanity. Siebren Bakker(Aevum Decessus) -BEGIN GEEK CODE BLOCK- Version: 3.12 GCS d- s+: a19 C UL++ P L++ !E W++ N(-) o? K? w(+) O? M-- V? PS+ PE Y- PGP- t+ 5? X- R tv-- b++ Di D+ G+ e h! r y- --END GEEK CODE BLOCK-- --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
user authentication example...login redirects
i've been trying to implement that scattered examples of user registration/authentication systems and without much success. I know it's due to my lack of sKiLLz or whatever, but I could use some help. The code i have creates my user and puts it into the database just fine..but after that, nothing happens... no flash, no redirect. I can't figure it out. here is my register code in the users_controller: function register() { if (!empty($this->data)) { if ($this->data['User']['password'] == $this->Auth- >password($this->data['User']['password_confirm'])) { $this->User->create(); $this->User->save($this->data); $this->redirect('login'); } } } what am I doing wrong? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---