get sso data

main
Wayne 3 years ago
parent 72c3f2575a
commit c380a40ec2

@ -21,15 +21,12 @@ class User extends ApiController
$user_data = [ $user_data = [
'user_id' => $this->uid 'user_id' => $this->uid
]; ];
$sso = Sso::getUserInfo($user_data);
$sso = Sso::getUserInfo($user_data);
if(!$sso['code']==200){ if(!$sso['code']==200){
return $this->error('get sso user info error!!!'); return $this->error('get sso user info error!!!');
} }
$sso_data = $sso['data']; $sso_data = $sso['data'];
try{ try{
$sso_data['level'] = 2; $sso_data['level'] = 2;
@ -37,7 +34,6 @@ class User extends ApiController
$sso_data['overdue_time'] = strtotime(date('Y-m-d',time() + (60 * 60 * 24 * 7))); $sso_data['overdue_time'] = strtotime(date('Y-m-d',time() + (60 * 60 * 24 * 7)));
$sso_data['cus_card'] = ''; $sso_data['cus_card'] = '';
$sso_data['create_time'] = date('Y-m-d H:i:s'); $sso_data['create_time'] = date('Y-m-d H:i:s');
Db::name('user') Db::name('user')
->insert($sso_data); ->insert($sso_data);

@ -12,7 +12,7 @@ class ApiService {
private $httpClient; private $httpClient;
private function __construct() { private function __construct() {
// 初始化 GuzzleHttp\Client 實例 // 初始化 GuzzleHttp\Client 實例
$this->httpClient = new \GuzzleHttp\Client([ $this->httpClient = new \GuzzleHttp\Client([
'base_uri' => env('utel.sso_base_url').'/api/v1/' 'base_uri' => env('utel.sso_base_url').'/api/v1/'
]); ]);
@ -33,13 +33,11 @@ class ApiService {
$options = ['query' => $params]; $options = ['query' => $params];
$response = $this->httpClient->request($method, $url, $options); $response = $this->httpClient->request($method, $url, $options);
if($response->getStatusCode()!=200){ if($response->getStatusCode()!=200){
//throw 異常; //throw 異常;
throw new Exception('get sso user info error!!!'); throw new Exception('get sso user info error!!!');
} }
$sso_data = json_decode($response->getBody()->getContents(),true);
$sso_data = json_decode($response->getBody()->getContents(),true);
return $sso_data; return $sso_data;
} }
} }

@ -4,9 +4,9 @@ namespace app\service;
use app\service\ApiService; use app\service\ApiService;
class Sso{ class Sso{
public static function getUserInfo($params){ public static function getUserInfo($params){
$apiService = ApiService::getInstance(); $apiService = ApiService::getInstance();
$response = $apiService->callApi('user/getInfo', 'GET', $params); $response = $apiService->callApi('user/getInfo', 'GET', $params);
return $response; return $response;
} }
} }

101
composer.lock generated

@ -305,16 +305,16 @@
}, },
{ {
"name": "guzzlehttp/psr7", "name": "guzzlehttp/psr7",
"version": "1.9.0", "version": "1.9.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/guzzle/psr7.git", "url": "https://github.com/guzzle/psr7.git",
"reference": "e98e3e6d4f86621a9b75f623996e6bbdeb4b9318" "reference": "e4490cabc77465aaee90b20cfc9a770f8c04be6b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/e98e3e6d4f86621a9b75f623996e6bbdeb4b9318", "url": "https://api.github.com/repos/guzzle/psr7/zipball/e4490cabc77465aaee90b20cfc9a770f8c04be6b",
"reference": "e98e3e6d4f86621a9b75f623996e6bbdeb4b9318", "reference": "e4490cabc77465aaee90b20cfc9a770f8c04be6b",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -333,11 +333,6 @@
"laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses"
}, },
"type": "library", "type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.9-dev"
}
},
"autoload": { "autoload": {
"files": [ "files": [
"src/functions_include.php" "src/functions_include.php"
@ -395,7 +390,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/guzzle/psr7/issues", "issues": "https://github.com/guzzle/psr7/issues",
"source": "https://github.com/guzzle/psr7/tree/1.9.0" "source": "https://github.com/guzzle/psr7/tree/1.9.1"
}, },
"funding": [ "funding": [
{ {
@ -411,7 +406,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-06-20T21:43:03+00:00" "time": "2023-04-17T16:00:37+00:00"
}, },
{ {
"name": "jeroendesloovere/vcard", "name": "jeroendesloovere/vcard",
@ -658,25 +653,25 @@
}, },
{ {
"name": "psr/http-message", "name": "psr/http-message",
"version": "1.0.1", "version": "1.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/php-fig/http-message.git", "url": "https://github.com/php-fig/http-message.git",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" "reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", "url": "https://api.github.com/repos/php-fig/http-message/zipball/cb6ce4845ce34a8ad9e68117c10ee90a29919eba",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", "reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.3.0" "php": "^7.2 || ^8.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.0.x-dev" "dev-master": "1.1.x-dev"
} }
}, },
"autoload": { "autoload": {
@ -705,9 +700,9 @@
"response" "response"
], ],
"support": { "support": {
"source": "https://github.com/php-fig/http-message/tree/master" "source": "https://github.com/php-fig/http-message/tree/1.1"
}, },
"time": "2016-08-06T14:39:51+00:00" "time": "2023-04-04T09:50:52+00:00"
}, },
{ {
"name": "psr/log", "name": "psr/log",
@ -1216,16 +1211,16 @@
}, },
{ {
"name": "topthink/framework", "name": "topthink/framework",
"version": "v6.1.1", "version": "v6.1.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/top-think/framework.git", "url": "https://github.com/top-think/framework.git",
"reference": "2cb56f3e6f3c479fe90ea5f28d38d3b5ef6c4210" "reference": "67235be5b919aaaf1de5aed9839f65d8e766aca3"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/top-think/framework/zipball/2cb56f3e6f3c479fe90ea5f28d38d3b5ef6c4210", "url": "https://api.github.com/repos/top-think/framework/zipball/67235be5b919aaaf1de5aed9839f65d8e766aca3",
"reference": "2cb56f3e6f3c479fe90ea5f28d38d3b5ef6c4210", "reference": "67235be5b919aaaf1de5aed9839f65d8e766aca3",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1237,7 +1232,7 @@
"psr/log": "~1.0", "psr/log": "~1.0",
"psr/simple-cache": "^1.0", "psr/simple-cache": "^1.0",
"topthink/think-helper": "^3.1.1", "topthink/think-helper": "^3.1.1",
"topthink/think-orm": "^2.0" "topthink/think-orm": "^2.0|^3.0"
}, },
"require-dev": { "require-dev": {
"guzzlehttp/psr7": "^2.1.0", "guzzlehttp/psr7": "^2.1.0",
@ -1275,27 +1270,27 @@
], ],
"support": { "support": {
"issues": "https://github.com/top-think/framework/issues", "issues": "https://github.com/top-think/framework/issues",
"source": "https://github.com/top-think/framework/tree/v6.1.1" "source": "https://github.com/top-think/framework/tree/v6.1.2"
}, },
"time": "2022-10-26T03:48:53+00:00" "time": "2023-02-08T02:24:01+00:00"
}, },
{ {
"name": "topthink/think-filesystem", "name": "topthink/think-filesystem",
"version": "v2.0.1", "version": "v2.0.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/top-think/think-filesystem.git", "url": "https://github.com/top-think/think-filesystem.git",
"reference": "50af34c4cfc9a5cbe8a5e3ac9f4e2aa0fd90693f" "reference": "c08503232fcae0c3c7fefae5e6b5c841ffe09f2f"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/top-think/think-filesystem/zipball/50af34c4cfc9a5cbe8a5e3ac9f4e2aa0fd90693f", "url": "https://api.github.com/repos/top-think/think-filesystem/zipball/c08503232fcae0c3c7fefae5e6b5c841ffe09f2f",
"reference": "50af34c4cfc9a5cbe8a5e3ac9f4e2aa0fd90693f", "reference": "c08503232fcae0c3c7fefae5e6b5c841ffe09f2f",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"league/flysystem": "^2.0", "league/flysystem": "^2.0",
"topthink/framework": "^6.1" "topthink/framework": "^6.1|^8.0"
}, },
"require-dev": { "require-dev": {
"mikey179/vfsstream": "^1.6", "mikey179/vfsstream": "^1.6",
@ -1321,9 +1316,9 @@
"description": "The ThinkPHP6.1 Filesystem Package", "description": "The ThinkPHP6.1 Filesystem Package",
"support": { "support": {
"issues": "https://github.com/top-think/think-filesystem/issues", "issues": "https://github.com/top-think/think-filesystem/issues",
"source": "https://github.com/top-think/think-filesystem/tree/v2.0.1" "source": "https://github.com/top-think/think-filesystem/tree/v2.0.2"
}, },
"time": "2023-01-06T14:29:27+00:00" "time": "2023-02-08T01:23:42+00:00"
}, },
{ {
"name": "topthink/think-helper", "name": "topthink/think-helper",
@ -1373,21 +1368,21 @@
}, },
{ {
"name": "topthink/think-multi-app", "name": "topthink/think-multi-app",
"version": "v1.0.15", "version": "v1.0.16",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/top-think/think-multi-app.git", "url": "https://github.com/top-think/think-multi-app.git",
"reference": "387e0dac059c20f92cac5da41a871e10829c1c97" "reference": "07b9183855150455e1f76f8cbe9d77d6d1bc399f"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/top-think/think-multi-app/zipball/387e0dac059c20f92cac5da41a871e10829c1c97", "url": "https://api.github.com/repos/top-think/think-multi-app/zipball/07b9183855150455e1f76f8cbe9d77d6d1bc399f",
"reference": "387e0dac059c20f92cac5da41a871e10829c1c97", "reference": "07b9183855150455e1f76f8cbe9d77d6d1bc399f",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=7.1.0", "php": ">=7.1.0",
"topthink/framework": "^6.0" "topthink/framework": "^6.0|^8.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
@ -1415,22 +1410,22 @@
"description": "thinkphp6 multi app support", "description": "thinkphp6 multi app support",
"support": { "support": {
"issues": "https://github.com/top-think/think-multi-app/issues", "issues": "https://github.com/top-think/think-multi-app/issues",
"source": "https://github.com/top-think/think-multi-app/tree/v1.0.15" "source": "https://github.com/top-think/think-multi-app/tree/v1.0.16"
}, },
"time": "2022-10-26T08:03:06+00:00" "time": "2023-02-07T08:40:09+00:00"
}, },
{ {
"name": "topthink/think-orm", "name": "topthink/think-orm",
"version": "v2.0.56", "version": "v2.0.61",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/top-think/think-orm.git", "url": "https://github.com/top-think/think-orm.git",
"reference": "75b8512736daaa056d511f42c15bed87c9f3605a" "reference": "10528ebf4a5106b19c3bac9c6deae7a67ff49de6"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/top-think/think-orm/zipball/75b8512736daaa056d511f42c15bed87c9f3605a", "url": "https://api.github.com/repos/top-think/think-orm/zipball/10528ebf4a5106b19c3bac9c6deae7a67ff49de6",
"reference": "75b8512736daaa056d511f42c15bed87c9f3605a", "reference": "10528ebf4a5106b19c3bac9c6deae7a67ff49de6",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1470,9 +1465,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/top-think/think-orm/issues", "issues": "https://github.com/top-think/think-orm/issues",
"source": "https://github.com/top-think/think-orm/tree/v2.0.56" "source": "https://github.com/top-think/think-orm/tree/v2.0.61"
}, },
"time": "2022-12-15T02:52:53+00:00" "time": "2023-04-20T14:27:51+00:00"
} }
], ],
"packages-dev": [ "packages-dev": [
@ -1733,21 +1728,21 @@
}, },
{ {
"name": "topthink/think-trace", "name": "topthink/think-trace",
"version": "v1.5", "version": "v1.6",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/top-think/think-trace.git", "url": "https://github.com/top-think/think-trace.git",
"reference": "55027fd79abb744f32a3be8d9e1ccf873a3ca9b7" "reference": "136cd5d97e8bdb780e4b5c1637c588ed7ca3e142"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/top-think/think-trace/zipball/55027fd79abb744f32a3be8d9e1ccf873a3ca9b7", "url": "https://api.github.com/repos/top-think/think-trace/zipball/136cd5d97e8bdb780e4b5c1637c588ed7ca3e142",
"reference": "55027fd79abb744f32a3be8d9e1ccf873a3ca9b7", "reference": "136cd5d97e8bdb780e4b5c1637c588ed7ca3e142",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=7.1.0", "php": ">=7.1.0",
"topthink/framework": "^6.0" "topthink/framework": "^6.0|^8.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
@ -1778,9 +1773,9 @@
"description": "thinkphp debug trace", "description": "thinkphp debug trace",
"support": { "support": {
"issues": "https://github.com/top-think/think-trace/issues", "issues": "https://github.com/top-think/think-trace/issues",
"source": "https://github.com/top-think/think-trace/tree/v1.5" "source": "https://github.com/top-think/think-trace/tree/v1.6"
}, },
"time": "2022-10-26T07:56:45+00:00" "time": "2023-02-07T08:36:32+00:00"
} }
], ],
"aliases": [], "aliases": [],

Loading…
Cancel
Save