Exemple #1
0
 public function sendConfirmEmail()
 {
     if ($this->email_verified == 'True') {
         return false;
     }
     $this->generate_key();
     $html_email = View::factory('register/verify_email_html');
     $text_email = View::factory('register/verify_email_text');
     $link = url::site('register/verify/?' . 'key=' . $this->activation_key . '&id=' . $this->id);
     View::bind_global('link', $link);
     $email = new Model_Email();
     $email->message(array($this->email => $this->fullname()), '[Code-Wars] Welcome to Code-Wars', $html_email, $text_email);
     $this->new_email = false;
     $this->save();
     return true;
 }
Exemple #2
0
 public function action_recover_request()
 {
     $view = View::factory('login/recover');
     if ('POST' == $_SERVER['REQUEST_METHOD']) {
         $post = new Validate($_POST);
         $post->rules('email', array('not_empty' => array(), 'email' => array()));
         if ($post->check()) {
             $user = ORM::factory('user')->where('email', '=', $post['email'])->find();
             if ('True' == $user->email_verified) {
                 $user->generate_key();
                 $user->save();
                 /*
                           //send an email
                           $q = new Pheanstalk_Model('codewars-email');
                           $q->put('password:'******'login/recover_email_html');
                 $text_email = View::factory('login/recover_email_text');
                 $link = url::site('login/recover/?' . 'key=' . $user->activation_key . '&id=' . $user->id);
                 View::bind_global('link', $link);
                 $email = new Model_Email();
                 $messages = $email->message(array($user->email => $user->fullname()), '[Code-Wars] Password Recovery', $html_email, $text_email);
                 if (false === $messages) {
                     $view->set('message', 'Looks like email has not been configured serverside');
                 } else {
                     $view = View::factory('login/recover_sent');
                 }
             } else {
                 $view->set('message', 'Your email address was not verified we can not send you a password recovery email');
             }
         } else {
             $view->set('message', $post->errors('login_errors'));
         }
     }
     $this->request->response = $view;
 }