8d78e18267
- Frontend: React 18 + TypeScript + Vite + Ant Design Mobile - Backend: PHP 8.5 + Webman 2.x + MySQL + Redis - i18n support: Chinese, English, Russian, Spanish, French - Approval workflow engine - Docker development environment - Feishu integration Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
60 lines
1.4 KiB
PHP
60 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Controller;
|
|
|
|
use App\Util\JwtUtil;
|
|
use Webman\Http\Request;
|
|
use Webman\Http\Response;
|
|
|
|
class AuthController extends BaseController
|
|
{
|
|
/**
|
|
* 用户登录
|
|
*/
|
|
public function login(Request $request): Response
|
|
{
|
|
$username = $request->post('username');
|
|
$password = $request->post('password');
|
|
|
|
// TODO: 实现真实的登录逻辑
|
|
if (!$username || !$password) {
|
|
return $this->error('用户名或密码不能空');
|
|
}
|
|
|
|
// 模拟用户数据
|
|
$user = [
|
|
'user_id' => 1,
|
|
'username' => $username,
|
|
'name' => '测试用户',
|
|
'company_id' => 1,
|
|
];
|
|
|
|
$token = JwtUtil::encode($user);
|
|
|
|
return $this->success([
|
|
'token' => $token,
|
|
'user' => $user,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* 飞书免登
|
|
*/
|
|
public function feishuLogin(Request $request): Response
|
|
{
|
|
$authCode = $request->post('auth_code');
|
|
$tenantKey = $request->post('tenant_key');
|
|
|
|
// TODO: 实现飞书免登逻辑
|
|
// 1. 根据 tenant_key 获取公司配置
|
|
// 2. 使用 auth_code 换取用户信息
|
|
// 3. 创建或更新用户
|
|
// 4. 生成 JWT Token
|
|
|
|
return $this->success([
|
|
'token' => JwtUtil::encode(['user_id' => 1, 'company_id' => 1]),
|
|
'user' => ['id' => 1, 'name' => '飞书用户', 'company_id' => 1],
|
|
]);
|
|
}
|
|
}
|