Commit 9479ff2d by 杨树贤

邮箱发送问题

parent 53659135
......@@ -192,18 +192,27 @@ class AuthApiController extends Controller
return $this->setError($validator->errors()->first());
}
$info = UserModel::where('email', $email)->first();
$msg = '';
switch ($type) {
case 'register':
if ($info) {
return $this->setError('This email had been registered');
// return $this->setError('This email had been registered');
}
$msg = 'You are registering an account with us.';
break;
case 'forget_password' :
$msg = 'You are trying to reset your password.';
$existEmail = UserModel::where('email', $email)->exists();
if (!$existEmail) {
return $this->setError('This email is not registered');
}
break;
case 'update_email':
$existEmail = UserModel::where('email', $email)->exists();
if (!$existEmail) {
return $this->setError('This email is not registered');
}
$msg = 'You are modifying your email address.';
break;
}
......@@ -216,10 +225,8 @@ class AuthApiController extends Controller
}
Redis::set($redisKey, $code);
Redis::expire($redisKey, 120);
$subject = config('mail.from.name');
// return $this->setSuccessData($code);
Mail::to($email)->send(new SendCode($type, $code));
Mail::to($email)->send(new SendCode($code, $msg));
//错误处理
if (count(Mail::failures())) {
return $this->setError('Email code send failed');
......
......@@ -11,18 +11,18 @@ class SendCode extends Mailable
{
use Queueable, SerializesModels;
public $type;
public $code;
public $msg;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($type,$code)
public function __construct($code, $msg)
{
$this->type = $type;
$this->code = $code;
$this->msg = $msg;
}
/**
......
......@@ -10,33 +10,14 @@
<div>
<img style="width: 25%;" src="https://img.ichunt.com/images/ichunt/202211/22/c0a944d0d89fde3ba67477369eac1bb2.png">
</div>
@if($type=='register')
<div style="margin-top: 50px">
<p>Hi!</p>
<p>You are registering an account with us.</p>
<p>{{$msg}}</p>
<p>You can enter this code on SEMOUR website:</p>
<span style="font-size: 20px"><strong>{{$code}}</strong></span>
<p>If this was not you, please let us know at INFO@semour.com</p>
</div>
@endif
@if($type=='update_email')
<div style="margin-top: 50px">
<p>Hi!</p>
<p>You are modifying your email address.</p>
<p>You can enter this code on SEMOUR website:</p>
<span style="font-size: 20px"><strong>{{$code}}</strong></span>
<p>If this was not you, please let us know at INFO@semour.com</p>
</div>
@endif
@if($type=='reset_password')
<div style="margin-top: 50px">
<p>Hi!</p>
<p>You are trying to reset your password.</p>
<p>You can enter this code on SEMOUR website:</p>
<span style="font-size: 20px"><strong>{{$code}}</strong></span>
<p>If this was not you, please let us know at INFO@semour.com</p>
</div>
@endif
</div>
</body>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment