完善接口逻辑,验证码接入
This commit is contained in:
30
Http/Controllers/Api/SmsController.php
Normal file
30
Http/Controllers/Api/SmsController.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Google2FA\Http\Controllers\Api;
|
||||
|
||||
use App\Api\Controllers\Controller;
|
||||
use Jason\Api\Api;
|
||||
use Modules\User\Facades\Sms;
|
||||
use Overtrue\EasySms\Exceptions\InvalidArgumentException;
|
||||
use Overtrue\EasySms\Exceptions\NoGatewayAvailableException;
|
||||
|
||||
class SmsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Notes : 获取验证码
|
||||
*
|
||||
* @Date : 2022/12/2 11:54
|
||||
* @Author : <Jason.C>
|
||||
*/
|
||||
public function send()
|
||||
{
|
||||
$user = Api::user();
|
||||
|
||||
try {
|
||||
Sms::sendVerificationCode($user->getMobile(), 'G2FA');
|
||||
return $this->success('验证码发送成功');
|
||||
} catch (InvalidArgumentException|NoGatewayAvailableException $e) {
|
||||
return $this->failed($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user