You've already forked guangan
用户绑定
This commit is contained in:
33
plugs/think-plugs-cms/src/controller/api/auth/Bind.php
Normal file
33
plugs/think-plugs-cms/src/controller/api/auth/Bind.php
Normal 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("未定义的业务");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user