forked from vivo-project/Vitro
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added refresh button for default challenge.
- Loading branch information
1 parent
262b99a
commit 83c553b
Showing
5 changed files
with
83 additions
and
1 deletion.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
api/src/main/java/edu/cornell/mannlib/vitro/webapp/beans/RefreshCaptchaController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package edu.cornell.mannlib.vitro.webapp.beans; | ||
|
||
import java.io.IOException; | ||
import java.io.PrintWriter; | ||
|
||
import javax.servlet.ServletException; | ||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import com.twelvemonkeys.servlet.HttpServlet; | ||
|
||
@WebServlet(name = "refreshCaptcha", urlPatterns = {"/refreshCaptcha"}, loadOnStartup = 5) | ||
public class RefreshCaptchaController extends HttpServlet { | ||
|
||
protected void doGet(HttpServletRequest request, HttpServletResponse response) | ||
throws ServletException, IOException { | ||
String oldChallengeId = request.getParameter("oldChallengeId"); | ||
|
||
response.setContentType("application/json"); | ||
PrintWriter out = response.getWriter(); | ||
|
||
CaptchaBundle newChallenge = CaptchaServiceBean.generateChallenge(); | ||
CaptchaServiceBean.getCaptchaChallenges().invalidate(oldChallengeId); | ||
CaptchaServiceBean.getCaptchaChallenges().put(newChallenge.getCaptchaId(), newChallenge); | ||
|
||
out.println("{\"challenge\": \"" + newChallenge.getB64Image() + "\", \"challengeId\": \"" + | ||
newChallenge.getCaptchaId() + "\"}"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters