作者 zhl

Merge branch 'develop' of 47.244.231.31:zhl/globalso-v6 into develop

@@ -31,12 +31,12 @@ class ComController extends BaseController @@ -31,12 +31,12 @@ class ComController extends BaseController
31 */ 31 */
32 public function login(){ 32 public function login(){
33 $this->request->validate([ 33 $this->request->validate([
34 - 'mobile'=>['required'], 34 + 'mobile'=>['required', 'regex:/^1[3-9]\d{9}$/'],
35 'password'=>['required'], 35 'password'=>['required'],
36 ],[ 36 ],[
37 'mobile.required'=>'电话号码必须填写', 37 'mobile.required'=>'电话号码必须填写',
38 'password.required'=>'内容必须填写', 38 'password.required'=>'内容必须填写',
39 - 'mobile.max' => 'mobile不大于12字符.', 39 + 'mobile.regex' => '请输入正确的手机号码',
40 ]); 40 ]);
41 $userModel = new UserModel(); 41 $userModel = new UserModel();
42 $res = $userModel->login($this->param); 42 $res = $userModel->login($this->param);
@@ -122,62 +122,6 @@ class ComController extends BaseController @@ -122,62 +122,6 @@ class ComController extends BaseController
122 $this->response('success'); 122 $this->response('success');
123 } 123 }
124 124
125 -  
126 - /**  
127 - * @name : (测试定时任务)检测用户是否无操作记录  
128 - * @author :lyh  
129 - * @method :post  
130 - * @time :2023/5/12 14:55  
131 - */  
132 - protected function ceShi(){  
133 - $this->error = 0;  
134 - //获取所有ayr_share用户  
135 - $ayr_share_model = new AyrShareModel();  
136 - $ayr_share_list = $ayr_share_model->list($this->map);  
137 - if(!empty($ayr_share_list)){  
138 - foreach ($ayr_share_list as $k => $v){  
139 - //查询当前用户是否有未推送的博文  
140 - $ayr_release = new AyrReleaseModel();  
141 - $release_info = $ayr_release->read(['schedule_date'=>['>',date('Y-m-d H:i:s',time())],'share_id'=>$v['id']]);  
142 - //有推文时,直接跳出循环  
143 - if($release_info !== false){  
144 - continue;  
145 - }  
146 - //查看用户是否在一周内有发送博客  
147 - $start_at = Carbon::now()->modify('-7 days')->toDateString();  
148 - $end_at = Carbon::now()->toDateString();  
149 - $release_info = $ayr_release->read(['created_at'=>['between',[$start_at,$end_at]]]);  
150 - //有发送博文,则跳出循环  
151 - if($release_info == false){  
152 - continue;  
153 - }  
154 - //删除用户第三方配置  
155 - $ayr_share_helper = new AyrShareHelper();  
156 - $data_profiles = [  
157 - 'title'=>$v['title'],  
158 - 'profileKey'=>$v['profile_key']  
159 - ];  
160 - $res = $ayr_share_helper->deleted_profiles($data_profiles);  
161 - if($res['status'] == 'fail'){  
162 - $this->error++;  
163 - continue;  
164 - }  
165 - //更新数据库  
166 - $data = [  
167 - 'title'=>null,  
168 - 'bind_plat_from'=>null,  
169 - 'profile_key'=>null,  
170 - 'ref_id'=>null,  
171 - ];  
172 - $res = $ayr_share_model->edit($data,['id'=>$v['id']]);  
173 - if($res == false){  
174 - $this->error++;  
175 - }  
176 - }  
177 - }  
178 - return $this->error;  
179 - }  
180 -  
181 /** 125 /**
182 * 发送登录短信 126 * 发送登录短信
183 * @param Request $request 127 * @param Request $request
@@ -191,25 +135,24 @@ class ComController extends BaseController @@ -191,25 +135,24 @@ class ComController extends BaseController
191 'mobile.required' => '手机号码不能为空', 135 'mobile.required' => '手机号码不能为空',
192 'mobile.regex' => '请输入正确的手机号码', 136 'mobile.regex' => '请输入正确的手机号码',
193 ]); 137 ]);
194 -  
195 $mobile = $request->input('mobile'); 138 $mobile = $request->input('mobile');
196 $user = User::where(['mobile' => $mobile])->first(); 139 $user = User::where(['mobile' => $mobile])->first();
197 - if (empty($user)) 140 + if (empty($user)) {
198 return $this->response('请输入正确的手机号码!', Code::USER_LOGIN_ERROE); 141 return $this->response('请输入正确的手机号码!', Code::USER_LOGIN_ERROE);
199 - 142 + }
200 $last_sms = SmsLog::getLastLog($mobile, SmsLog::TYPE_LOGIN); 143 $last_sms = SmsLog::getLastLog($mobile, SmsLog::TYPE_LOGIN);
201 - if ($last_sms && $last_sms->use = SmsLog::USE_USABLE && time() - strtotime($last_sms->created_at) < 60) 144 + if ($last_sms && $last_sms->use = SmsLog::USE_USABLE && time() - strtotime($last_sms->created_at) < 60) {
202 return $this->response('请不要重复发送短信!', Code::USER_LOGIN_ERROE); 145 return $this->response('请不要重复发送短信!', Code::USER_LOGIN_ERROE);
203 - 146 + }
204 $template = config('alisms.login_sms_temp'); 147 $template = config('alisms.login_sms_temp');
205 $code['code'] = rand(100000,999999); 148 $code['code'] = rand(100000,999999);
206 $ali_sms = new AliSms(); 149 $ali_sms = new AliSms();
207 $send = $ali_sms->sendSms(strval($mobile), $template, $code); 150 $send = $ali_sms->sendSms(strval($mobile), $template, $code);
208 - if (empty($send->Code) && $send->Code != 'OK') 151 + if (empty($send->Code) && $send->Code != 'OK') {
209 return $this->response('发送失败, 请稍后重试!', Code::USER_LOGIN_ERROE); 152 return $this->response('发送失败, 请稍后重试!', Code::USER_LOGIN_ERROE);
210 -  
211 - SmsLog::createLog($mobile, $code['code'], SmsLog::TYPE_LOGIN);  
212 - return $this->response('success', Code::SUCCESS); 153 + }
  154 + SmsLog::createLog($mobile, $code['code']);
  155 + return $this->response('success');
213 } 156 }
214 157
215 } 158 }
@@ -5,6 +5,7 @@ namespace App\Models\User; @@ -5,6 +5,7 @@ namespace App\Models\User;
5 //use Illuminate\Contracts\Auth\MustVerifyEmail; 5 //use Illuminate\Contracts\Auth\MustVerifyEmail;
6 use App\Helper\Common; 6 use App\Helper\Common;
7 use App\Models\Base; 7 use App\Models\Base;
  8 +use App\Models\SmsLog;
8 use App\Models\User\ProjectRole as ProjectRoleModel; 9 use App\Models\User\ProjectRole as ProjectRoleModel;
9 use Illuminate\Database\Eloquent\Factories\HasFactory; 10 use Illuminate\Database\Eloquent\Factories\HasFactory;
10 use Illuminate\Notifications\Notifiable; 11 use Illuminate\Notifications\Notifiable;
@@ -59,17 +60,20 @@ class User extends Base @@ -59,17 +60,20 @@ class User extends Base
59 * @method 60 * @method
60 */ 61 */
61 public function login($param){ 62 public function login($param){
62 - if(!isset($param['login_method'])){  
63 - //密码加密  
64 - $param['password'] = base64_encode(md5($param['password']));  
65 - $info = $this->read(['mobile'=>$param['mobile']  
66 - ,'password'=>$param['password'],'status'=>0], ['id','mobile','role_id','token','name','project_id']);  
67 - }else{  
68 - //TODO::验证验证码是否正确  
69 - $info = $this->read(['mobile'=>$param['mobile']],['*']);  
70 - } 63 + //验证账号密码
  64 + $password = base64_encode(md5($param['password']));
  65 + $info = $this->read(['mobile'=>$param['mobile'],'password'=>$password,'status'=>0], ['id','mobile','role_id','token','name','project_id']);
71 if($info === false){ 66 if($info === false){
72 - return false; 67 + //账号密码没通过时,验证验证码
  68 + $info = $this->read(['mobile'=>$param['mobile'],'status'=>0], ['id','mobile','role_id','token','name','project_id']);
  69 + if($info === false){
  70 + return false;
  71 + }
  72 + //验证验证码是否准备
  73 + $last_sms = SmsLog::getLastLog($param['mobile'], SmsLog::TYPE_LOGIN);
  74 + if($param['password'] != $last_sms->code){
  75 + return false;
  76 + }
73 } 77 }
74 //当前用户角色是否被禁用 78 //当前用户角色是否被禁用
75 $projectRoleModel = new ProjectRoleModel(); 79 $projectRoleModel = new ProjectRoleModel();
@@ -119,5 +123,4 @@ class User extends Base @@ -119,5 +123,4 @@ class User extends Base
119 Cache::pull($info['token']); 123 Cache::pull($info['token']);
120 return true; 124 return true;
121 } 125 }
122 -  
123 } 126 }
@@ -293,7 +293,7 @@ Route::middleware(['bloginauth'])->group(function () { @@ -293,7 +293,7 @@ Route::middleware(['bloginauth'])->group(function () {
293 //无需登录验证的路由组 293 //无需登录验证的路由组
294 Route::group([], function () { 294 Route::group([], function () {
295 Route::any('/login', [\App\Http\Controllers\Bside\ComController::class, 'login'])->name('login'); 295 Route::any('/login', [\App\Http\Controllers\Bside\ComController::class, 'login'])->name('login');
296 - Route::any('/', [\App\Http\Controllers\Bside\ComController::class, 'ceShi'])->name('ce_shi'); 296 + Route::any('/sendLoginSms', [\App\Http\Controllers\Bside\ComController::class, 'sendLoginSms'])->name('sendLoginSms');
297 Route::get('/file/download', [\App\Http\Controllers\Bside\FileController::class, 'download'])->name('file_download'); 297 Route::get('/file/download', [\App\Http\Controllers\Bside\FileController::class, 'download'])->name('file_download');
298 Route::any('/image/{hash}/{w?}/{h?}', [\App\Http\Controllers\File\ImageController::class,'index'])->name('image_show'); 298 Route::any('/image/{hash}/{w?}/{h?}', [\App\Http\Controllers\File\ImageController::class,'index'])->name('image_show');
299 Route::any('/file_hash/{hash}', [\App\Http\Controllers\File\FileController::class,'index'])->name('file_show'); 299 Route::any('/file_hash/{hash}', [\App\Http\Controllers\File\FileController::class,'index'])->name('file_show');