dootask/app/Http/Controllers/Api/LicenseController.php
kuaifan 7c6b8ce6f4 feat(license): 在线授权登录与试用改为邮箱+验证码
配合 appstore 账号体系统一,在线授权去除 App Store 账号+密码:
- OnlineLicense 新增 emailSend,login/trial 改 (email, code),call payload
  去 account/password、加 email/code(fingerprint 续传)
- LicenseController 新增 email__send,login/trial 读 email/code
- license.vue 在线 Tab 改邮箱+发码+验证码(与试用复用状态防串台),
  离线 Tab 与互斥链路不动
- 同步 i18n 文案与 ai-kb license/online、api-map
2026-06-23 01:21:11 +00:00

96 lines
2.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Http\Controllers\Api;
use App\Models\User;
use App\Module\Base;
use App\Module\OnlineLicense;
use Request;
/**
* 在线授权客户端(与 SystemController::license 的离线粘贴并存)。
*
* 动态路由routes/web.php
* api/license/email/send -> email__send()
* api/license/login -> login()
* api/license/trial -> trial()
* api/license/status -> status()
* api/license/refresh -> refresh()
* api/license/logout -> logout()
*/
class LicenseController extends AbstractController
{
/**
* 发送邮箱验证码(登录与试用共用)
*/
public function email__send()
{
User::auth('admin');
$email = trim(Request::input('email'));
if ($email === '') {
return Base::retError('请输入邮箱');
}
$masked = OnlineLicense::emailSend($email);
return Base::retSuccess('验证码已发送', ['email' => $masked]);
}
/**
* 邮箱 + 验证码登录并签发在线授权
*/
public function login()
{
User::auth('admin');
$email = trim(Request::input('email'));
$code = trim(Request::input('code'));
if ($email === '' || $code === '') {
return Base::retError('请输入邮箱和验证码');
}
$data = OnlineLicense::login($email, $code);
return Base::retSuccess('授权成功', $data);
}
/**
* 邮箱 + 验证码申请试用并签发
*/
public function trial()
{
User::auth('admin');
$email = trim(Request::input('email'));
$code = trim(Request::input('code'));
if ($email === '' || $code === '') {
return Base::retError('请输入邮箱和验证码');
}
$data = OnlineLicense::trial($email, $code);
return Base::retSuccess('试用已开通', $data);
}
/**
* 当前在线授权状态
*/
public function status()
{
User::auth('admin');
return Base::retSuccess('success', OnlineLicense::status());
}
/**
* 进入授权页时的静默刷新:服务可达则更新授权数据,网络失败则不更新、不提示。
*/
public function refresh()
{
User::auth('admin');
OnlineLicense::refresh();
return Base::retSuccess('success', OnlineLicense::status());
}
/**
* 退出在线授权(释放座位 + 回落默认)
*/
public function logout()
{
User::auth('admin');
OnlineLicense::logout();
return Base::retSuccess('已退出在线授权');
}
}