|
@@ -25,8 +25,7 @@ class Sms extends Api
|
|
|
public function send()
|
|
|
{
|
|
|
$mobile = $this->request->post("mobile");
|
|
|
- $event = $this->request->post("event");
|
|
|
- $event = $event ? $event : 'register';
|
|
|
+ $event = 'default';
|
|
|
|
|
|
if (!$mobile || !\think\Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
$this->error(__('手机号不正确'));
|
|
@@ -39,22 +38,7 @@ class Sms extends Api
|
|
|
if ($ipSendTotal >= 5) {
|
|
|
$this->error(__('发送频繁'));
|
|
|
}
|
|
|
- if ($event) {
|
|
|
- $userinfo = User::getByMobile($mobile);
|
|
|
- if ($event == 'register' && $userinfo) {
|
|
|
- //已被注册
|
|
|
- $this->error(__('已被注册'));
|
|
|
- } elseif (in_array($event, ['changemobile']) && $userinfo) {
|
|
|
- //被占用
|
|
|
- $this->error(__('已被占用'));
|
|
|
- } elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) {
|
|
|
- //未注册
|
|
|
- $this->error(__('未注册'));
|
|
|
- }
|
|
|
- }
|
|
|
- if (!Hook::get('sms_send')) {
|
|
|
- $this->error(__('请在后台插件管理安装短信验证插件'));
|
|
|
- }
|
|
|
+
|
|
|
$ret = Smslib::send($mobile, null, $event);
|
|
|
if ($ret) {
|
|
|
$this->success(__('发送成功'));
|
|
@@ -74,26 +58,13 @@ class Sms extends Api
|
|
|
public function check()
|
|
|
{
|
|
|
$mobile = $this->request->post("mobile");
|
|
|
- $event = $this->request->post("event");
|
|
|
- $event = $event ? $event : 'register';
|
|
|
+ $event = 'default';
|
|
|
$captcha = $this->request->post("captcha");
|
|
|
|
|
|
if (!$mobile || !\think\Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
$this->error(__('手机号不正确'));
|
|
|
}
|
|
|
- if ($event) {
|
|
|
- $userinfo = User::getByMobile($mobile);
|
|
|
- if ($event == 'register' && $userinfo) {
|
|
|
- //已被注册
|
|
|
- $this->error(__('已被注册'));
|
|
|
- } elseif (in_array($event, ['changemobile']) && $userinfo) {
|
|
|
- //被占用
|
|
|
- $this->error(__('已被占用'));
|
|
|
- } elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) {
|
|
|
- //未注册
|
|
|
- $this->error(__('未注册'));
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
$ret = Smslib::check($mobile, $captcha, $event);
|
|
|
if ($ret) {
|
|
|
$this->success(__('成功'));
|