Right. My bad. Good looking out!
Thanks guys J From: [email protected] [mailto:[email protected]] On Behalf Of André Luis Sent: Friday, May 10, 2013 8:53 AM To: [email protected] Subject: Re: Validate Question It´s not a rule model have no access to components, you can get it on any method inside any model using AuthComponent::user('user_id'), that´s why some components have some static method, an example of this is when you create a user and need to hash the password before it saves... on model User: public function beforeSave($options = array()) { parent::beforeSave($options); if(isset($this->data[$this->alias]['password'])) $this->data[$this->alias]['password' ]= AuthComponent::password($this->data[$this->alias]['password']); return true; } This way is recommended by cake book, you can check it here: http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html #hashing-passwords Also you can use SessionComponent::read() if needed... Em sexta-feira, 10 de maio de 2013 07h54min52s UTC-3, advantage+ escreveu: If the model has no access to Ssession data from correct MVC structure how do you validate user_id in the model when saving records? Auth saves the user_id in the session when logged in but if you cannot get that in the model how do you verify the user_id? -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out. -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
