|
|
@@ -146,12 +146,15 @@ class AuthController extends PublicController
|
|
|
$appId = $merchant['miniAppId'];
|
|
|
$appSecret = $merchant['miniAppSecret'];
|
|
|
$url = "https://api.weixin.qq.com/sns/jscode2session?appid={$appId}&secret={$appSecret}&js_code={$code}&grant_type=authorization_code";
|
|
|
-
|
|
|
+
|
|
|
$curl = new curl\Curl();
|
|
|
$result = $curl->get($url);
|
|
|
$arr = Json::decode($result);
|
|
|
$sessionKey = isset($arr['session_key']) ? $arr['session_key'] : '';
|
|
|
$openid = isset($arr['openid']) ? $arr['openid'] : '';
|
|
|
+ if (empty($openid)) {
|
|
|
+ util::fail('没有获取到小程序openId');
|
|
|
+ }
|
|
|
//用户来源
|
|
|
$userSource = UserClass::$userSourceId['mini']['name'];
|
|
|
$user = UserService::getByMiniOpenId($openid, $account);
|
|
|
@@ -167,5 +170,5 @@ class AuthController extends PublicController
|
|
|
$token = jwt::getNewToken($userId);
|
|
|
util::success(['token' => $token, 'user' => $user]);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|