shish 3 лет назад
Родитель
Сommit
16b24c9620
1 измененных файлов с 18 добавлено и 0 удалено
  1. 18 0
      app-mall/controllers/UserController.php

+ 18 - 0
app-mall/controllers/UserController.php

@@ -17,6 +17,24 @@ use yii\helpers\Json;
 class UserController extends BaseController
 {
 
+    //使用账号登录 ssh 20220920
+    public function actionAccountLogin()
+    {
+        $get = Yii::$app->request->get();
+        $mobile = $get['mobile'] ?? '';
+        $password = $get['password'] ?? '';
+        if ($password != 'a.1234') {
+            util::fail('密码错误')
+        }
+        $user = UserClass::getByCondition(['mobile' => $mobile], true);
+        if (empty($user)) {
+            util::fail('账号无效');
+        }
+        $userId = $user->id ?? 0;
+        $token = !empty($userId) ? jwt::getNewToken($userId) : '';
+        util::success(['user' => $user, 'token' => $token]);
+    }
+
     //创建用户和客户 ssh 20220607
     public function actionCreate()
     {