Ejemplo n.º 1
0
 public function forgotpassword()
 {
     if ($this->responseTerminal()) {
         $db = avail::$database->select('*')->from($this->table)->where($this->formPost)->execute()->rowsId()->toObject();
         if ($db->rowsCount) {
             $taskId = avail::assist('password')->sha1($db->rows->userid);
             $taskCode = avail::assist()->uniqid();
             $taskQuery = array('taskid' => 'password-user-' . $db->rows->userid, 'code' => $taskCode, 'status' => 1, 'userid' => $db->rows->userid, 'subject' => 'reset password');
             $status = avail::mail(array('email/reset.password' => $taskQuery))->send();
             if ($status) {
                 avail::$database->insert($taskQuery)->to('tasks')->duplicateUpdate($taskQuery)->execute();
             }
             $msg = array(avail::language('Verification code has been sent')->get(), avail::language('Mail could not send')->get());
             $this->responseTask($status, $Id, $db, $msg);
         } else {
             $this->message = avail::language('no VALUE exists')->get(array('value' => avail::arrays($this->formPost)->to_sentence()));
             $this->responseTaskerror($Id, $db, $this->message);
         }
     }
     return $this;
 }