Skip to content

Commit

Permalink
Merge pull request #17 from encorelab/revert-16-merge-with-wise-api-j…
Browse files Browse the repository at this point in the history
…un-2023

Revert "chore: Merge with wise api jun 2023"
  • Loading branch information
hirokiterashima authored Sep 21, 2023
2 parents d6cfb30 + 9c8ddc5 commit c8a7240
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 23 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.wise.portal.domain.authentication.MutableUserDetails;
import org.wise.portal.domain.user.User;
import org.wise.portal.presentation.web.controllers.ControllerUtil;
import org.wise.portal.presentation.web.exception.RecaptchaVerificationException;
import org.wise.portal.service.user.UserService;

import javax.servlet.ServletException;
Expand Down Expand Up @@ -76,28 +75,35 @@ public void onAuthenticationFailure(HttpServletRequest request, HttpServletRespo
Integer numberOfRecentFailedLoginAttempts = 1;
Date currentTime = new Date();
if (ControllerUtil.isRecentFailedLoginWithinTimeLimit(user)) {
numberOfRecentFailedLoginAttempts = userDetails.getNumberOfRecentFailedLoginAttempts()
+ 1;
numberOfRecentFailedLoginAttempts = userDetails.getNumberOfRecentFailedLoginAttempts() + 1;
}
userDetails.setNumberOfRecentFailedLoginAttempts(numberOfRecentFailedLoginAttempts);
userDetails.setRecentFailedLoginTime(currentTime);
userService.updateUser(user);
}
} else if (request.getServletPath().contains("google-login")) {
response.sendRedirect(
appProperties.getProperty("wise.hostname") + "/join?googleUserNotFound=true");
response.sendRedirect(appProperties.getProperty("wise.hostname") + "/join?googleUserNotFound=true");
return;
}
if (exception instanceof RecaptchaVerificationException) {

if (this.isNewSite(request)) {
try {
JSONObject responseJSON = ControllerUtil.createErrorResponse();
responseJSON.put("isRecaptchaVerificationFailed", true);
responseJSON.put("isRecaptchaRequired", ControllerUtil.isReCaptchaRequired(request));
response.getWriter().write(responseJSON.toString());
} catch (JSONException e) {
}
} else {
//setDefaultFailureUrl(determineFailureUrl(request, response, exception));
//super.onAuthenticationFailure(request, response, exception);
}
}

private boolean isNewSite(HttpServletRequest request) {
String site = request.getParameter("site");
return "new".equals(site);
}

/**
* Get the failure url. This function checks if the public and private
* keys for the captcha have been provided and if the user has failed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.wise.portal.domain.user.User;
import org.wise.portal.presentation.web.controllers.ControllerUtil;
import org.wise.portal.presentation.web.exception.RecaptchaVerificationException;
import org.wise.portal.service.session.SessionService;
import org.wise.portal.service.user.UserService;

Expand Down Expand Up @@ -76,12 +75,13 @@ public class WISEAuthenticationProcessingFilter extends UsernamePasswordAuthenti
@Override
public Authentication attemptAuthentication(HttpServletRequest request,
HttpServletResponse response) throws AuthenticationException {
if (ControllerUtil.isReCaptchaEnabled()) {
String gReCaptchaResponse = request.getParameter("recaptchaResponse");
if (ControllerUtil.isReCaptchaRequired(request)) {
String gReCaptchaResponse = request.getParameter("g-recaptcha-response");
if (!ControllerUtil.isReCaptchaResponseValid(gReCaptchaResponse)) {
String errorMessage = "Please verify that you are not a robot.";
try {
unsuccessfulAuthentication(request, response,
new RecaptchaVerificationException("Recaptcha verification failed"));
unsuccessfulAuthentication(request, response, new AuthenticationException(errorMessage) {
});
} catch (IOException e) {

} catch (ServletException e) {
Expand Down

0 comments on commit c8a7240

Please sign in to comment.