123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- // +----------------------------------------------------------------------
- // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2017~2024 https://www.yiovo.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
- // +----------------------------------------------------------------------
- // | Author: 萤火科技 <admin@yiovo.com>
- // +----------------------------------------------------------------------
- declare (strict_types=1);
- namespace app\api\controller;
- use think\response\Json;
- use app\api\service\passport\{Captcha as CaptchaService, SmsCaptcha as SmsCaptchaService ,MailCaptcha as MailCaptchaService};
- use cores\exception\BaseException;
- /**
- * 验证码管理
- * Class Cart
- * @package app\api\controller
- */
- class Captcha extends Controller
- {
- /**
- * 图形验证码
- * @return Json
- */
- public function image(): Json
- {
- $CaptchaService = new CaptchaService;
- return $this->renderSuccess($CaptchaService->create());
- }
- /**
- * 发送短信验证码
- * @return Json
- * @throws BaseException
- */
- public function sendSmsCaptcha(): Json
- {
- $SmsCaptchaService = new SmsCaptchaService;
- if ($SmsCaptchaService->handle($this->postForm())) {
- return $this->renderSuccess('发送成功,请注意查收');
- }
- return $this->renderError($SmsCaptchaService->getError() ?: '短信发送失败');
- }
- /**
- * 发送邮箱验证码
- * @return Json
- * @throws BaseException
- */
- public function sendEmailCaptcha(): Json
- {
- $MailCaptchaService = new MailCaptchaService;
- if ($MailCaptchaService->handle($this->postForm())) {
- return $this->renderSuccess('Sent Successful!Please check your new mails.');
- }
- return $this->renderError($MailCaptchaService->getError() ?: '短信发送失败');
- }
- }
|