mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-22 06:50:53 +08:00
fix: 后端代码格式化
This commit is contained in:
@@ -1,35 +1,35 @@
|
||||
package com.openisle.service;
|
||||
|
||||
import java.util.Map;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* CaptchaService implementation using Google reCAPTCHA.
|
||||
*/
|
||||
@Service
|
||||
public class RecaptchaService extends CaptchaService {
|
||||
|
||||
@Value("${recaptcha.secret-key:}")
|
||||
private String secretKey;
|
||||
@Value("${recaptcha.secret-key:}")
|
||||
private String secretKey;
|
||||
|
||||
private final RestTemplate restTemplate = new RestTemplate();
|
||||
private final RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
@Override
|
||||
public boolean verify(String token) {
|
||||
if (token == null || token.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
String url = "https://www.google.com/recaptcha/api/siteverify?secret={secret}&response={response}";
|
||||
try {
|
||||
ResponseEntity<Map> resp = restTemplate.postForEntity(url, null, Map.class, secretKey, token);
|
||||
Map body = resp.getBody();
|
||||
return body != null && Boolean.TRUE.equals(body.get("success"));
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean verify(String token) {
|
||||
if (token == null || token.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
String url =
|
||||
"https://www.google.com/recaptcha/api/siteverify?secret={secret}&response={response}";
|
||||
try {
|
||||
ResponseEntity<Map> resp = restTemplate.postForEntity(url, null, Map.class, secretKey, token);
|
||||
Map body = resp.getBody();
|
||||
return body != null && Boolean.TRUE.equals(body.get("success"));
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user