用户绑定

This commit is contained in:
2025-03-26 10:31:48 +08:00
parent a728db86a0
commit 3ee101403b

View File

@ -0,0 +1,33 @@
<?php
namespace plugin\cms\controller\api\auth;
use plugin\cms\controller\api\Auth;
use think\admin\Exception;
use think\admin\Library;
class Bind extends Auth
{
public const tLogin = 'LOGIN';
public static $scenes = [
self::tLogin => '用户登录验证',
];
public function send()
{
$data = $this->_vali([
'phone.mobile' => '手机号错误',
'phone.require' => '手机号为空',
]);
Library::$sapp->cache->set(static::genCacheKey($data['phone']), ['code' => 123456, 'time' => time() + 300], 600);
$this->success("测试验证码123456");
}
private static function genCacheKey(string $phone, string $scene = self::tLogin): string
{
if (isset(array_change_key_case(static::$scenes)[strtolower($scene)])) {
return md5(strtolower("sms-{$scene}-{$phone}"));
} else {
throw new Exception("未定义的业务");
}
}
}