Commit 7b045638 authored by Matija Obreza's avatar Matija Obreza
Browse files

reCAPTCHA in .properties

parent 68d790ee
...@@ -30,6 +30,7 @@ import org.crophub.rest.common.model.UserRole; ...@@ -30,6 +30,7 @@ import org.crophub.rest.common.model.UserRole;
import org.crophub.rest.common.model.impl.User; import org.crophub.rest.common.model.impl.User;
import org.crophub.rest.common.service.UserService; import org.crophub.rest.common.service.UserService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
...@@ -53,6 +54,12 @@ public class HtmlController extends BaseController { ...@@ -53,6 +54,12 @@ public class HtmlController extends BaseController {
@Autowired @Autowired
private Validator validator; private Validator validator;
@Value("${captcha.privateKey}")
private String captchaPrivateKey;
@Value("${captcha.publicKey}")
private String captchaPublicKey;
@RequestMapping("/") @RequestMapping("/")
public String welcome() { public String welcome() {
return "redirect:/index.html"; return "redirect:/index.html";
...@@ -71,7 +78,8 @@ public class HtmlController extends BaseController { ...@@ -71,7 +78,8 @@ public class HtmlController extends BaseController {
} }
@RequestMapping(value = "registration.html") @RequestMapping(value = "registration.html")
public String registration() { public String registration(ModelMap model) {
model.addAttribute("captchaPublicKey", captchaPublicKey);
return "/registration"; return "/registration";
} }
...@@ -88,7 +96,7 @@ public class HtmlController extends BaseController { ...@@ -88,7 +96,7 @@ public class HtmlController extends BaseController {
// Probably don't want to hardcode your private key here but // Probably don't want to hardcode your private key here but
// just to get it working is OK... // just to get it working is OK...
reCaptcha.setPrivateKey("6LdwDuESAAAAAORNI10cwpgDMrGZbJteKGBu5ccI"); reCaptcha.setPrivateKey(captchaPrivateKey);
ReCaptchaResponse reCaptchaResponse = reCaptcha.checkAnswer(remoteAddr, challenge, response); ReCaptchaResponse reCaptchaResponse = reCaptcha.checkAnswer(remoteAddr, challenge, response);
......
...@@ -24,3 +24,8 @@ db.url=jdbc:mysql://192.168.56.101/aimprosoft?useUnicode=true&characterEncoding= ...@@ -24,3 +24,8 @@ db.url=jdbc:mysql://192.168.56.101/aimprosoft?useUnicode=true&characterEncoding=
db.driverClassName = com.mysql.jdbc.Driver db.driverClassName = com.mysql.jdbc.Driver
db.username = root db.username = root
db.password = mysql db.password = mysql
# reCAPTCHA API
captcha.privateKey=A
captcha.publicKey=B
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment