Beispiel #1
0
 public static function check($mobile, $code)
 {
     $model = CaptchaCode::find()->where(['mobile' => $mobile, 'status' => 0])->andWhere($and)->orderBy('created_at desc')->one();
     if (empty($model)) {
         return false;
     }
     if ($model->code != $code) {
         return false;
     }
     return $model;
 }
Beispiel #2
0
 public function validateSmsCode($attribute, $params)
 {
     $this->checkModel = CaptchaCode::find()->where(['mobile' => $this->Phone, 'status' => 0])->orderBy('created_at desc')->one();
     if (!$this->checkModel) {
         $this->addError('smsCode', '短信验证码错误1');
         return false;
     }
     if ($this->checkModel->code != $this->smsCode) {
         $this->addError('smsCode', '短信验证码错误2');
         return false;
     }
     if (CURRENT_TIMESTAMP - $this->checkModel->created_at > 600) {
         $this->addError('smsCode', '验证码已经过期');
         return false;
     }
     return true;
 }