public function testGetCustomer()
 {
     $result = HtCustomer::model()->getCustomer('*****@*****.**');
     $this->assertNotEmpty($result, 'Account should be found.');
     $result = HtCustomer::model()->getCustomer('13988888888');
     $this->assertEmpty($result, 'User should not be exists.');
 }
 public function authenticateWithoutPassword()
 {
     $user = HtCustomer::model()->find('LOWER(email)=?', array(strtolower($this->username)));
     if ($user === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         $this->_id = $user->customer_id;
         $this->username = $user->firstname;
         $this->errorCode = self::ERROR_NONE;
     }
     return !$this->errorCode;
 }
示例#3
0
 public function backgroundLogin($firstname, $email, $telephone)
 {
     if (!trim($firstname) || !trim($telephone) || !trim($email)) {
         $msg = '信息不完整!';
         return $msg;
     }
     $this->logout();
     $password = substr($telephone, -6);
     $this->customer_info = HtCustomer::model()->findAllByAttributes(array('email' => $email));
     if ($this->customer_info == null) {
         $this->customer_info = HtCustomer::model()->addBackgroundCustomer($email, $password, $telephone, $firstname);
         $new_register = true;
         // send email
         $config_name = Setting::instance()->get('config_name');
         $subject = sprintf('%s - 感谢您的注册', $config_name);
         $data = array('firstName' => $this->customer_info['firstname'], 'email' => $this->customer_info['email'], 'background_login' => true, 'BASE_URL' => Yii::app()->getBaseUrl(true), 'LOGIN_URL' => Yii::app()->homeUrl);
         Mail::sendToCustomer($email, $subject, Mail::getBody($data, HtNotifyTemplate::REGISTER_OK));
     } else {
         $new_register = false;
     }
     if ($this->login($email, '', true)) {
         Yii::app()->session['customer_email'] = $email;
         Yii::app()->session['new_register'] = $new_register;
     }
     return '';
 }