发送验证码

master
lion 6 months ago
parent 80b9065b86
commit b306b433d8

@ -312,12 +312,12 @@ class UserController extends CommonController
$messages = [ $messages = [
'mobile.required' => '手机号必填', 'mobile.required' => '手机号必填',
'mobile.numeric' => '手机号格式错误', 'mobile.numeric' => '手机号格式错误',
// 'code' => '验证码必填', 'code' => '验证码必填',
'is_bind' => '是否绑定必填', 'is_bind' => '是否绑定必填',
]; ];
$validator = Validator::make($all, [ $validator = Validator::make($all, [
'mobile' => 'required|numeric', 'mobile' => 'required|numeric',
// 'code' => 'required', 'code' => 'required',
'is_bind' => 'required', 'is_bind' => 'required',
], $messages); ], $messages);
if ($validator->fails()) { if ($validator->fails()) {
@ -361,19 +361,19 @@ class UserController extends CommonController
$messages = [ $messages = [
'mobile.required' => '手机号必填', 'mobile.required' => '手机号必填',
'mobile.numeric' => '手机号格式错误', 'mobile.numeric' => '手机号格式错误',
// 'code' => '验证码必填', 'code' => '验证码必填',
]; ];
$validator = Validator::make($all, [ $validator = Validator::make($all, [
'mobile' => 'required|numeric', 'mobile' => 'required|numeric',
// 'code' => 'required', 'code' => 'required',
], $messages); ], $messages);
if ($validator->fails()) { if ($validator->fails()) {
return $this->fail([StarterResponseCode::START_ERROR_PARAMETER, implode(',', $validator->errors()->all())]); return $this->fail([StarterResponseCode::START_ERROR_PARAMETER, implode(',', $validator->errors()->all())]);
} }
$key = 'sms_' . $all['mobile']; $key = 'sms_' . $all['mobile'];
$check = Cache::get($key); $check = Cache::get($key);
// if (empty($check)) return $this->fail([ResponseCode::ERROR_BUSINESS, '请先发送验证码']); if (empty($check)) return $this->fail([ResponseCode::ERROR_BUSINESS, '请先发送验证码']);
// if ($check['code'] != $all['code']) return $this->fail([ResponseCode::ERROR_BUSINESS, '验证码错误']); if ($check['code'] != $all['code']) return $this->fail([ResponseCode::ERROR_BUSINESS, '验证码错误']);
// 判断手机号是否存在 // 判断手机号是否存在
$hasMobile = User::where('mobile', $all['mobile'])->first(); $hasMobile = User::where('mobile', $all['mobile'])->first();
if ($hasMobile) { if ($hasMobile) {

Loading…
Cancel
Save