mirror of
https://github.com/librecaptcha/lc-core.git
synced 2025-01-27 13:03:12 -05:00
Minor fixes
Signed-off-by: Rahul Rudragoudar <rr83019@gmail.com>
This commit is contained in:
parent
fe9138dbaf
commit
f3f8900fd4
@ -92,16 +92,15 @@ class Captcha(throttle: Int) {
|
||||
|
||||
def getChallenge(param: Parameters): Id = {
|
||||
val rs = stmt.executeQuery("SELECT token FROM challenge WHERE solved=FALSE LIMIT 1")
|
||||
var id: String = null
|
||||
if(rs.next()){
|
||||
id = rs.getString("token")
|
||||
val id = if(rs.next()){
|
||||
rs.getString("token")
|
||||
} else {
|
||||
id = generateChallenge(param)
|
||||
generateChallenge(param)
|
||||
}
|
||||
Id(id)
|
||||
}
|
||||
|
||||
def getAnswer(answer: Answer): Boolean = {
|
||||
def checkAnswer(answer: Answer): Boolean = {
|
||||
selectPstmt.setString(1, answer.id)
|
||||
val rs: ResultSet = selectPstmt.executeQuery()
|
||||
rs.next()
|
||||
@ -169,7 +168,7 @@ class Server(port: Int){
|
||||
val body = req.getJson()
|
||||
val json = parse(body)
|
||||
val answer = json.extract[Answer]
|
||||
val result = captcha.getAnswer(answer)
|
||||
val result = captcha.checkAnswer(answer)
|
||||
resp.getHeaders().add("Content-Type","application/json")
|
||||
val responseContent = if(result) """{"result":"True"}""" else """{"result":"False"}"""
|
||||
resp.send(200,responseContent)
|
||||
|
Loading…
x
Reference in New Issue
Block a user