On May 14, 2:53 pm, LITTO CHACKO <[email protected]> wrote:
> i think if u return password from model and in the controller pass it to
> message what u set in flash..
> $this->Session->setFlash(__("The user has been
> saved".$pass));
> may be it works
Then the question would be how to return password from model :)
I've worked around the issue by simply storing the clear-text password
into a model variable in beforeSave(), and then passing it into a
template through a flash message after successfully saving the user:
It may be ugly, but works for me.
class User extends AppModel {
public function beforeSave() {
$this->cleartext_password = self::generatePassword();
$this->data[$this->alias]['password'] =
AuthComponent::password($this->cleartext_password);
return true;
}
...
class UsersController extends AppController {
public function add() {
if ($this->request->isPost()) {
$this->User->create();
if ($this->User->save($this->request->data)) {
$this->Session->setFlash(sprintf(__("The user has been
saved, password: %s", $this->User->cleartext_password)));
--
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
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php