登录中心功能开发
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace app\common\logic;
|
||||
|
||||
use app\common\model\Corp;
|
||||
use app\common\model\CorpFeishuApp;
|
||||
use app\common\model\UserTokenLog;
|
||||
use app\common\model\Systems;
|
||||
use app\common\model\User;
|
||||
@@ -375,6 +377,30 @@ class AuthLogic
|
||||
return $system;
|
||||
}
|
||||
|
||||
/**
|
||||
* 公司验证
|
||||
*/
|
||||
private function validateCorp(string $corpAbbr)
|
||||
{
|
||||
$corp = Corp::where('abbr', $corpAbbr)->first();
|
||||
if (!$corp) {
|
||||
throw new BusinessException('公司不存在', 403);
|
||||
}
|
||||
return $corp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 飞书应用信息
|
||||
*/
|
||||
private function validateFeishuApp(int $corpId, string $systemCode)
|
||||
{
|
||||
$feishuAppInfo = CorpFeishuApp::where('corp_id', $corpId)->where('system_code', $systemCode)->first();
|
||||
if (!$feishuAppInfo) {
|
||||
throw new BusinessException('飞书应用不存在', 403);
|
||||
}
|
||||
return $feishuAppInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户系统权限校验
|
||||
*/
|
||||
@@ -450,6 +476,16 @@ class AuthLogic
|
||||
*/
|
||||
private function getFeishuUserInfo(string $code)
|
||||
{
|
||||
// // 获取凭证
|
||||
// $certificate = certificate($param['state']);
|
||||
// // 获取token
|
||||
// $class = new Feishu($certificate['appId'], $certificate['appSecre_s'], $param['state']);
|
||||
// $userAccessToken = $class->userAccessToken($param['code'], $certificate['rUrl']);
|
||||
// // 获取用户信息
|
||||
// $rst = $class->userInfo($userAccessToken['access_token']);
|
||||
// if ($rst['code'] != 0) {
|
||||
// throw new BusinessException('授权失败,请重试');
|
||||
// }
|
||||
// 实际实现需要调用飞书 API
|
||||
return [
|
||||
'user_id' => 'feishu_user_123',
|
||||
@@ -472,4 +508,20 @@ class AuthLogic
|
||||
}
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* 飞书应用信息
|
||||
*/
|
||||
public function feishuAppInfo(string $corpAbbr, string $systemCode)
|
||||
{
|
||||
$corpInfo = $this->validateCorp($corpAbbr);
|
||||
$fsAppInfo = $this->validateFeishuApp($corpInfo->id, $systemCode);
|
||||
return [
|
||||
'app_id' => $fsAppInfo->app_id,
|
||||
'app_secret' => $fsAppInfo->app_secret,
|
||||
'r_url' => $fsAppInfo->r_url,
|
||||
'scope' => $fsAppInfo->scopes,
|
||||
'state' => $fsAppInfo->state
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user