ソースを参照

Wesmiler 人人车 初始化项目 0816

APPLE 3 年 前
コミット
98daba7e1a

+ 6 - 0
application/admin/controller/store/Taxi.php

@@ -221,6 +221,9 @@ class Taxi extends AdminController
         // 错误返回
         (true !== $valid) && IResponse::failure($valid);
         // 保存数据
+        if($params['password']){
+            $params['password'] = password_hash($params['password'],PASSWORD_DEFAULT);
+        }
         $taxiUserId = model('common/TaxiUser')->storeBy($params);
         if($taxiUserId){
             // 创建会员账号
@@ -261,6 +264,9 @@ class Taxi extends AdminController
         (true !== $valid) && IResponse::failure($valid);
 
         // 更新用户信息
+        if($params['password']){
+            $params['password'] = password_hash($params['password'],PASSWORD_DEFAULT);
+        }
         $driver->updateBy($id, $params);
 
         return IResponse::success('更新司机信息成功');

+ 3 - 0
application/api/controller/v1/taxi/User.php

@@ -56,6 +56,9 @@ class User extends ApiController
         $this->model->startTrans();
         try {
             $params['user_id'] = $user['id'];
+            if($params['password']){
+                $params['password'] = password_hash($params['password'],PASSWORD_DEFAULT);
+            }
             $result = $this->model::create($params, true);
             $this->model->commit();
         }

+ 1 - 1
config/mni.php

@@ -51,7 +51,7 @@ return [
             ],
             // agent 认证
             'taxi_user' => [
-                'driver' => 'jwt',
+                'driver' => 'orm',
                 'model' => \app\common\model\TaxiUser::class,
             ],
         ],

+ 3 - 3
route/route.php

@@ -45,10 +45,10 @@ Route::group('api',function (){
         // 公共
         Route::group('taxiuser',function () {
             // 登录
-            Route::post('/login','api/:ver.taxiUser/Auth/login');
+            Route::post('/login','api/:ver.taxiUser.Auth/login');
             // 司机找回密码
-            Route::post('/forget','api/:ver.taxiUser/Auth/forget');
-        })->header('Access-Control-Allow-Origin', 'http://'.request()->rootDomain().'/api')
+            Route::post('/forget','api/:ver.taxiUser.Auth/forget');
+        })->header('Access-Control-Allow-Origin', '*')
             ->header('Access-Control-Allow-Credentials', 'true')
             ->allowCrossDomain();;
 

+ 3 - 1
vendor/lettered/support/src/Auth.php

@@ -57,6 +57,7 @@ class Auth
     public function attempt($condition)
     {
         $user = $this->authenticate($condition);
+
         // 用户存在性
         if (!$user) {
             throw new FailedException([
@@ -142,6 +143,7 @@ class Auth
      */
     protected function jwt($user)
     {
+        var_dump($user);
         $token = JWTAuth::builder([$this->jwtKey() => $user->id]);
 
         JWTAuth::setToken($token);
@@ -257,7 +259,7 @@ class Auth
         $where = [];
         foreach ($condition as $field => $value) {
             if ($field == 'captcha') continue;
-            if (in_array($field,['username','email','open_id']))
+            if (in_array($field,['username','mobile','email','open_id']))
                 $where[$field] = preg_replace('# #','',$value);
         }
         return $where;