|
...
|
...
|
@@ -9,9 +9,11 @@ use App\Models\AyrShare\AyrRelease as AyrReleaseModel; |
|
|
|
use App\Models\AyrShare\AyrShare as AyrShareModel;
|
|
|
|
use App\Models\Project\Project;
|
|
|
|
use App\Models\Project\Project as ProjectModel;
|
|
|
|
use App\Models\SmsLog;
|
|
|
|
use App\Models\User\ProjectMenu as ProjectMenuModel;
|
|
|
|
use App\Models\User\ProjectRole as ProjectRoleModel;
|
|
|
|
use App\Models\User\User as UserModel;
|
|
|
|
use App\Models\User\User;
|
|
|
|
use Carbon\Carbon;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
...
|
...
|
@@ -176,4 +178,38 @@ class ComController extends BaseController |
|
|
|
return $this->error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 发送登录短信
|
|
|
|
* @param Request $request
|
|
|
|
* @return \Illuminate\Http\JsonResponse
|
|
|
|
*/
|
|
|
|
public function sendLoginSms(Request $request)
|
|
|
|
{
|
|
|
|
$this->request->validate([
|
|
|
|
'mobile'=>['required', 'regex:/^1[3-9]\d{9}$/'],
|
|
|
|
],[
|
|
|
|
'mobile.required' => '手机号码不能为空',
|
|
|
|
'mobile.regex' => '请输入正确的手机号码',
|
|
|
|
]);
|
|
|
|
|
|
|
|
$mobile = $request->input('mobile');
|
|
|
|
$user = User::where(['mobile' => $mobile])->first();
|
|
|
|
if (empty($user))
|
|
|
|
return $this->response('请输入正确的手机号码!', Code::USER_LOGIN_ERROE);
|
|
|
|
|
|
|
|
$last_sms = SmsLog::getLastLog($mobile, SmsLog::TYPE_LOGIN);
|
|
|
|
if ($last_sms && $last_sms->use = SmsLog::USE_USABLE && time() - strtotime($last_sms->created_at) < 60)
|
|
|
|
return $this->response('请不要重复发送短信!', Code::USER_LOGIN_ERROE);
|
|
|
|
|
|
|
|
$template = config('alisms.login_sms_temp');
|
|
|
|
$code['code'] = rand(100000,999999);
|
|
|
|
$ali_sms = new AliSms();
|
|
|
|
$send = $ali_sms->sendSms(strval($mobile), $template, $code);
|
|
|
|
if (empty($send->Code) && $send->Code != 'OK')
|
|
|
|
return $this->response('发送失败, 请稍后重试!', Code::USER_LOGIN_ERROE);
|
|
|
|
|
|
|
|
SmsLog::createLog($mobile, $code['code'], SmsLog::TYPE_LOGIN);
|
|
|
|
return $this->response('success', Code::SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
} |
...
|
...
|
|