公共登录 - 手机后、账号同时可作为登录条件

This commit is contained in:
柳清爽
2025-04-30 14:52:51 +08:00
parent f75c5fc310
commit df72ab8095
8 changed files with 275 additions and 186 deletions

View File

@@ -0,0 +1,39 @@
<?php
namespace app\common\controller;
use library\ResponseHelper;
use think\facade\Request;
/**
* 认证控制器
* 处理用户登录和身份验证
*/
class SendCodeController extends BaseController
{
/**
* 发送验证码
* @return \think\response\Json
*/
public function index()
{
$params = $this->request->only(['account', 'type']);
// 参数验证
$validate = validate('common/Auth');
if (!$validate->scene('send_code')->check($params)) {
return ResponseHelper::error($validate->getError());
}
try {
// 调用发送验证码服务
$result = $this->authService->sendLoginCode(
$params['account'],
$params['type']
);
return ResponseHelper::success($result, '验证码发送成功');
} catch (\Exception $e) {
return ResponseHelper::error($e->getMessage());
}
}
}