Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function forgotten_password(){
- if(!empty($this->data)){
- $conditions['User.email'] = $this->data['User']['email'];
- $user = $this->User->find($conditions);
- if(!empty($user)){
- $newPass = substr(hash('md5', uniqid()), rand(0, 24), 8);
- $this->Email->charset = 'utf-8';
- $this->Email->xMailer = Configure::read('App.name').' Mail Component';
- $this->Email->sendAs = 'html';
- $this->Email->delivery = 'mail';
- $this->Email->to = $user['User']['email'];
- $this->Email->from = Configure::read('App.email_from');
- $this->Email->subject = Configure::read('App.name').': Password changed';
- $content = array(
- 'name'=>$user['User']['name'].' '.$user['User']['surname'].' '.$user['User']['lastname'],
- 'email'=>($user['User']['email']!=$user['User']['username']?$user['User']['username']:$user['User']['email']),
- 'passwd'=>$newPass
- );
- $this->set('contentData', $content);
- if ($this->Email->send($content, 'password')){
- $this->Session->setFlash(__('Password sent successfully', true));
- $this->User->save(array('id'=>$user['User']['id'], 'passwd'=>$newPass));
- $this->redirect('/');
- }else{
- $this->Session->setFlash(__('sending problem', true));
- }
- }else{
- $this->Session->setFlash(__('Неизвестен потребител или грешен E-mail!', true));
- }
- }
- }
Add Comment
Please, Sign In to add comment