Commit 9479ff2d by 杨树贤

邮箱发送问题

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