Skip to content

Commit

Permalink
Show error if token has expired when resetting password.
Browse files Browse the repository at this point in the history
  • Loading branch information
Portals committed Jun 16, 2024
1 parent 888f5fd commit 47704e0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
6 changes: 0 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ apply plugin: "io.spring.dependency-management"
group = "it.chalmers"
version = "2.0.0-SNAPSHOT"

bootBuildImage {
environment = [
'JAVA_TOOL_OPTIONS': '-XX:MaxRAM=10g'
]
}

dependencies {
annotationProcessor(
// Used to generate Record Builder classes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package it.chalmers.gamma.adapter.primary.web;

import static it.chalmers.gamma.adapter.primary.web.WebValidationHelper.validateObject;

import it.chalmers.gamma.app.common.Email.EmailValidator;
import it.chalmers.gamma.app.user.domain.Cid.CidValidator;
import it.chalmers.gamma.app.user.passwordreset.UserResetPasswordFacade;
import it.chalmers.gamma.app.user.passwordreset.domain.PasswordResetRepository;
import it.chalmers.gamma.app.validation.FailedValidation;
import it.chalmers.gamma.app.validation.SuccessfulValidation;
import it.chalmers.gamma.app.validation.ValidationResult;
Expand All @@ -16,8 +19,6 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import static it.chalmers.gamma.adapter.primary.web.WebValidationHelper.validateObject;

@Controller
public class ForgotPasswordController {

Expand Down Expand Up @@ -145,6 +146,12 @@ public ModelAndView finalizeForgotPassword(
throw new RuntimeException(e);
} catch (IllegalArgumentException e) {
bindingResult.addError(new ObjectError("global", e.getMessage()));
} catch (PasswordResetRepository.TokenNotFoundRuntimeException e) {
bindingResult.addError(
new ObjectError("global", "Token has expired, please restart the reset flow."));
}

if (bindingResult.hasErrors()) {
return createGetFinalizeForgotPassword(
htmxRequest, new FinalizeForgotPassword(form.token, "", ""), bindingResult);
}
Expand Down

0 comments on commit 47704e0

Please sign in to comment.