CaptchaServiceController.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Services\CallApiService;
  4. use Illuminate\Http\Request;
  5. class CaptchaServiceController extends Controller
  6. {
  7. private $callApiService;
  8. public function __construct(CallApiService $callApiService)
  9. {
  10. $this->callApiService = $callApiService;
  11. }
  12. public function capthcaFormValidate(Request $request)
  13. {
  14. $rules = ['captcha' => 'required|captcha'];
  15. $validator = validator()->make(request()->all(), $rules);
  16. if ($validator->fails()) {
  17. notify()->error('문자열 입력이 틀렸습니다', 'Error', 'bottomRight');
  18. return redirect()->to('506');
  19. } else {
  20. $response = $this->callApiService->callApi([
  21. 'url' => 'gate-token-cleaning',
  22. 'data' => [
  23. '' => ''
  24. ],
  25. ]);
  26. if ($this->callApiService->verifyApiError($response)) {
  27. notify()->error('API 에러', 'Error', 'bottomRight');
  28. return redirect()->to('506');
  29. }
  30. notify()->success('휴먼 증명 되었습니다', 'Success', 'bottomRight');
  31. return redirect()->to(session()->get('previous_url'));
  32. }
  33. }
  34. public function reloadCaptcha()
  35. {
  36. return response()->json(['captcha'=> captcha_img()]);
  37. }
  38. }