tongshanglei 1 gadu atpakaļ
vecāks
revīzija
094157df4e

+ 9 - 2
catch/login/controller/Index.php

@@ -23,8 +23,14 @@ class Index extends CatchController
     public function login(LoginRequest $request, CatchAuth $auth)
     {
         $condition = $request->param();
-
+        $need_update=false;
         try {
+ 
+            $password = $condition['password']; 
+            if (!preg_match('/^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]{8,}$/', $password)) {
+                $need_update=true;
+            } 
+           
             $token = $auth->attempt($condition);
 
             $user = $auth->user();
@@ -36,7 +42,8 @@ class Index extends CatchController
             return CatchResponse::success([
                 'token' => $token,
 				'user_id' => $user->id,
-                'realname'=>$user->realname,
+                'realname'=>$user->username,
+                'need_update'=>$need_update,
                 "phone"=>$user->phone
             ], '登录成功');
         } catch (\Exception $exception) {

+ 19 - 1
catch/permissions/controller/User.php

@@ -80,7 +80,17 @@ class User extends CatchController
        $params=$request->param();
       
        //$params['realname']=$params['username'];
-     
+       if(isset($params['password']) && ($params['password']!='')){
+            $password = $params['password']; // 假设密码是 p@ssw0rd
+
+            if (preg_match('/^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]{8,}$/', $password)) {
+            
+            } else {
+                return CatchResponse::fail('密码不符合规则');
+            }
+       }
+      
+
         $this->user->storeBy($params);
 
         $this->user->attachRoles($request->param('roles'));
@@ -117,7 +127,15 @@ class User extends CatchController
     {
         $params=$request->param();
         // $params['area_id']=json_encode($params['area_id']);
+        if(isset($params['password']) && ($params['password']!='')){
+            $password = $params['password']; // 假设密码是 p@ssw0rd
 
+            if (preg_match('/^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]{8,}$/', $password)) {
+            
+            } else {
+                return CatchResponse::fail('密码不符合规则');
+            }
+       }
         if($params['password']==""){
             unset($params['password']);
         }