added any validation yet but the sign up doesn't seem to want to work.
I set $this->data['User']['confirm_code'] as well as the level of the
user. But neither the password, confirm_code , or level get saved. I
was told that input named password is already hashed so I had to
create hash the second password.
As well when the data is submitted, the page isn't rendered , it is
just blank. The email gets sent and all. It seems as if the
beforeFilter isn't working. Any help would be appreciated.
var $name = 'Users';
var $components = array('Auth','Email');
function beforeFilter() {
$this->Auth->allow('signup');
}
function signup() {
if (!empty($this->data)) {
if(isset($this->data['User']['password2'])) {
$this->data['User']['password2hashed'] = $this->Auth-
>password($this->data['User']['password2']);
}
$this->User->create();
$this->data['User']['level'] = 'member';
$this->data['User']['confirm_code'] = String::uuid();
if ($this->User->save($this->data)) {
$this->Email->to = $this->data['User']['email'];
$this->Email->subject = 'Email Confirmation';
$this->Email->replyto = 'thatsgreat2345@gmail.com';
$this->Email->from = 'thatsgreat2345@gmail.com';
$this->Email->sendAs = 'html';
$this->Email->template = 'confirmation';
$this->set('name',$this->data['User']['username']);
$this->set('server_name',$_SERVER['SERVER_NAME']);
$this->set('id',$this->User->getLastInsertID());
$this->set('code',$this->data['User']['confirm_code']);
if ($this->Email->send()) {
$this->Session->setFlash('Confirmation email has been
sent.');
$this-
>redirect(array('controller'=>'questions','action'=>'home'),null,true);
} else {
$this->User->del($this->User->getLastInsertID());
$this->Session->setFlash('There was an error signing
up');
}
} else {
$this->Session->setFlash('There was an error signing up.
Please, try again.');
$this->data = null;
}
}
}
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment