EmailCertificationController.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace App\Http\Controllers\V3;
  3. use App\Http\Controllers\Controller;
  4. use App\Http\Requests\V3\StoreEmailCertificationRequest;
  5. use App\Services\V3\SignUpService;
  6. /**
  7. * 注册邮箱验证码。
  8. *
  9. * 取代 `POST /v2/email-certification`(`EmailCertificationController@store`)。
  10. * v2 那份在 dashboard-v4 下线前原样保留,不要改动。v2 的
  11. * `GET /v2/email-certification/{id}` 会把验证码交给前端比对,v3 没有对应端点——
  12. * 比对改在服务端做,见 `POST /v3/invites`。
  13. */
  14. class EmailCertificationController extends Controller
  15. {
  16. public function __construct(private readonly SignUpService $signUp) {}
  17. /**
  18. * 发送注册验证码
  19. *
  20. * 向邮箱发一个 6 位验证码,30 分钟内有效;重复申请会作废上一个。
  21. * 邮箱已注册时返回 422。按 IP 与邮箱限流,超出返回 429。
  22. *
  23. * @unauthenticated
  24. *
  25. * @bodyParam email string required 待注册的邮箱。Example: someone@example.com
  26. * @bodyParam lang string 邮件语言,没有对应模板的回落 en。Enum: en,en-US,zh-Hans,zh-Hant
  27. *
  28. * @responseStatus 204 已发送,无响应体
  29. * @responseStatus 429 请求过于频繁
  30. * @responseStatus 503 邮件发送失败
  31. */
  32. public function store(StoreEmailCertificationRequest $request)
  33. {
  34. $this->signUp->sendCode($request->validated('email'), $request->validated('lang'));
  35. return response()->noContent();
  36. }
  37. }