Esempio n. 1
0
 public function sendVerifyEmail($request, $response, $args)
 {
     $res = [];
     $email = $request->getParam('email');
     if (!Check::isEmailLegal($email)) {
         $res['ret'] = 0;
         $res['error_code'] = self::VerifyEmailWrongEmail;
         $res['msg'] = '邮箱无效';
         return $this->echoJson($response, $res);
     }
     // check email
     $user = User::where('email', $email)->first();
     if ($user != null) {
         $res['ret'] = 0;
         $res['error_code'] = self::VerifyEmailExist;
         $res['msg'] = "邮箱已经被注册了";
         return $this->echoJson($response, $res);
     }
     if (EmailVerify::sendVerification($email)) {
         $res['ret'] = 1;
         $res['msg'] = '验证代码已发送至您的邮箱,请在登录邮箱后将验证码填到相应位置.';
         return $this->echoJson($response, $res);
     }
     $res['ret'] = 0;
     $res['msg'] = '邮件发送失败,请联系管理员';
     return $this->echoJson($response, $res);
 }
Esempio n. 2
0
 public function sendVerifyEmail($request, $response, $next)
 {
     $res = array();
     $email = $request->getParam('email');
     if (!Check::isEmailLegal($email)) {
         $res['ret'] = 0;
         $res['msg'] = '邮箱无效';
         return $this->echoJson($response, $res);
     }
     // check email
     $user = User::where('email', $email)->first();
     if ($user != null) {
         $res['ret'] = 0;
         $res['msg'] = "邮箱已经被注册了";
         return $this->echoJson($response, $res);
     }
     if (EmailVerify::sendVerification($email)) {
         $res['ret'] = 1;
         $res['msg'] = '验证代码已发送至您的邮箱,请在登录邮箱后将验证码填到相应位置.';
     } else {
         $res['ret'] = 0;
         $res['msg'] = '邮件发送失败,请联系管理员';
     }
     return $this->echoJson($response, $res);
 }