发送验证码

master
lion 6 months ago
parent 80b9065b86
commit b306b433d8

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

Loading…
Cancel
Save