Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CCAP-661] - handle incorrect confirmation code #1200

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 21 additions & 19 deletions src/main/java/org/ilgcc/app/ProviderLinkController.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import static org.ilgcc.app.utils.constants.SessionKeys.SESSION_KEY_FAMILY_SUBMISSION_ID;
import static org.ilgcc.app.utils.constants.SessionKeys.SESSION_KEY_SUBMISSION_MAP;

Expand All @@ -33,7 +34,7 @@ public ProviderLinkController(SubmissionRepositoryService submissionRepositorySe
* @param utmMedium The utm_medium param, likely email vs message vs blank
* @return
*/
@GetMapping(value = {"providerresponse/submit","providerresponse/submit/{confirmationCode}"})
@GetMapping(value = {"providerresponse/submit", "providerresponse/submit/{confirmationCode}"})
String loadFamilySubmission(HttpSession session, HttpServletRequest request,
@PathVariable(required = false) String confirmationCode,
@RequestParam(name = "utm_medium", required = false) String utmMedium) {
Expand All @@ -49,26 +50,27 @@ String loadFamilySubmission(HttpSession session, HttpServletRequest request,
String sanitizedUtmMedium = (utmMedium != null) ? utmMedium.replace('\n', '_').replace('\r', '_') : null;
log.info("Loading submission for code " + sanitizedConfirmationCode + " from medium " + sanitizedUtmMedium);

if (sanitizedConfirmationCode != null) {
Optional<Submission> submission = submissionRepositoryService.findByShortCode(sanitizedConfirmationCode);
if (submission.isPresent()) {
Submission s = submission.get();
Map<String, String> urlParams = s.getUrlParams();
if (urlParams == null) {
urlParams = new HashMap<String, String>();
}

// TODO: Is this necessary? We probably want to save/set these on the *new* Submission for the provider
urlParams.put("utm_medium", sanitizedUtmMedium);
urlParams.put("conf_code", sanitizedConfirmationCode);
s.setUrlParams(urlParams);
submissionRepositoryService.save(s);
if (null == sanitizedConfirmationCode || sanitizedConfirmationCode.isBlank()) {
return "redirect:/error-invalid-code";
}
Optional<Submission> submission = submissionRepositoryService.findByShortCode(sanitizedConfirmationCode);

newSession.setAttribute(SESSION_KEY_FAMILY_SUBMISSION_ID, s.getId());
} else {
log.error("Unable to load submission for code " + sanitizedConfirmationCode);
return "redirect:/error";
if (submission.isPresent()) {
Submission s = submission.get();
Map<String, String> urlParams = s.getUrlParams();
if (urlParams == null) {
urlParams = new HashMap<String, String>();
}

// TODO: Is this necessary? We probably want to save/set these on the *new* Submission for the provider
urlParams.put("utm_medium", sanitizedUtmMedium);
urlParams.put("conf_code", sanitizedConfirmationCode);
s.setUrlParams(urlParams);
submissionRepositoryService.save(s);

newSession.setAttribute(SESSION_KEY_FAMILY_SUBMISSION_ID, s.getId());
} else {
return "redirect:/error-invalid-code";
}

return "redirect:/flow/providerresponse/submit-start";
Expand Down
98 changes: 54 additions & 44 deletions src/main/java/org/ilgcc/app/StaticPageController.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,54 +13,64 @@
*/
@Controller
public class StaticPageController {

FormFlowConfigurationProperties formFlowConfigurationProperties;

public StaticPageController(FormFlowConfigurationProperties formFlowConfigurationProperties) {
this.formFlowConfigurationProperties = formFlowConfigurationProperties;
}
FormFlowConfigurationProperties formFlowConfigurationProperties;

/**
* Renders the website index page.
*
* @param httpSession The current HTTP session, not null.
* @return the static page template.
*/
@GetMapping("/")
ModelAndView getIndex(HttpSession httpSession) {
httpSession.invalidate(); // For dev, reset session if you visit home
public StaticPageController(FormFlowConfigurationProperties formFlowConfigurationProperties) {
this.formFlowConfigurationProperties = formFlowConfigurationProperties;
}

HashMap<String, Object> model = new HashMap<>();
return new ModelAndView("index", model);
}
/**
* Renders the website index page.
*
* @param httpSession The current HTTP session, not null.
* @return the static page template.
*/
@GetMapping("/")
ModelAndView getIndex(HttpSession httpSession) {
httpSession.invalidate(); // For dev, reset session if you visit home

/**
* Renders the website faq page.
*
* @return the static page template
*/
@GetMapping("/faq")
String getFaq() {
return "faq";
}
HashMap<String, Object> model = new HashMap<>();
return new ModelAndView("index", model);
}

/**
* Renders the website privacy page.
*
* @return the static page template
*/
@GetMapping("/privacy")
String getPrivacy() {
return "privacy";
}
/**
* Renders the website faq page.
*
* @return the static page template
*/
@GetMapping("/faq")
String getFaq() {
return "faq";
}

/**
* Renders the page to redirect to when a flow is disabled.
*
* @return the static page template
*/
@GetMapping("/disabledFeature")
String getDisabled() {
return "disabledFeature";
}
/**
* Renders the website privacy page.
*
* @return the static page template
*/
@GetMapping("/privacy")
String getPrivacy() {
return "privacy";
}

/**
* Renders the page to redirect to when a flow is disabled.
*
* @return the static page template
*/
@GetMapping("/disabledFeature")
String getDisabled() {
return "disabledFeature";
}

/**
* Renders the error invalid code screen
*
* @return the static page template
*/
@GetMapping("/error-invalid-code")
String getInvalidCode() {
return "error-invalid-code";
}
}
7 changes: 7 additions & 0 deletions src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,13 @@ confirm-delivery.yes-continue=Yes, continue
confirm-delivery.no-go-back=No, go back

#provider-response

#error-invalid-code
error-invalid-code.title=Invalid confirmation code
error-invalid-code.header=Enter a valid confirmation code
error-invalid-code.subtext=Your confirmation code is a combination of 6 numbers and letters.
error-invalid-code.button=Return to homepage

#submit-start
provider-response-submit-start.title=Start response
provider-response-submit-start.active.header=Hi, {0}!
Expand Down
29 changes: 29 additions & 0 deletions src/main/resources/templates/error-invalid-code.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html th:lang="${#locale.language}">
<head th:replace="~{fragments/head :: head(title=#{error-invalid-code.title})}"></head>
<body>
<div class="page-wrapper">
<div th:replace="~{fragments/toolbar :: toolbar}"></div>
<section class="slab">
<div class="grid">
<div th:replace="~{fragments/goBack :: goBackLink}"></div>
<main id="content" role="main" class="form-card spacing-above-35">
<th:block th:replace="~{fragments/gcc-icons :: code}"></th:block>
<th:block
th:replace="~{fragments/cardHeader :: cardHeader(header=#{error-invalid-code.header}, subtext=#{error-invalid-code.subtext})}"/>
<div class="form-card__content">
</div>
<div class="form-card__footer">
<a
href="/"
data-mixpanel="invalid-code-return-home"
th:text="#{error-invalid-code.button}"
class="button--primary button"></a>
</div>
</main>
</div>
</section>
</div>
<th:block th:replace="~{fragments/footer :: footer}"/>
</body>
</html>
27 changes: 27 additions & 0 deletions src/main/resources/templates/fragments/gcc-icons.html
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,33 @@ <h1>GCC Icons (Matches Figma Icon Name)</h1>
</svg>
</td>
</tr>
<tr>
<td>code</td>
<td>
<svg th:fragment="code" aria-hidden="true" width="101" height="75"
viewBox="0 0 101 75" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd"
d="M49.3641 69.286C39.3847 68.3619 28.4231 68.872 21.9478 61.2114C15.308 53.3563 15.7571 42.1893 17.9634 32.1376C20.1976 21.9587 24.9296 12.4152 33.8401 7.03147C43.9177 0.942532 56.5019 -2.69467 67.0883 2.45622C77.6451 7.59275 80.969 20.0406 83.9453 31.4106C87.1016 43.4685 92.3711 57.7555 83.9719 66.9549C75.7633 75.9454 61.4768 70.4076 49.3641 69.286Z"
fill="#E6A001"/>
<path d="M68.7854 7.02858L33.7462 7C30.8885 7 28.5711 9.3222 28.5711 12.1946L28.5 62.0682C28.4929 64.9406 30.8103 67.2771 33.668 67.2771L72.1337 67.3056C74.9914 67.3056 77.3089 64.9834 77.3089 62.1111L77.3799 15.8029L68.7854 7.02858Z"
fill="white"/>
<path d="M68.7854 15.8038L68.7854 7.02858L77.3089 15.8038H68.7854Z"
fill="white"/>
<path d="M68.7854 7.02858L33.7462 7C30.8885 7 28.5711 9.3222 28.5711 12.1946L28.5 62.0682C28.4929 64.9406 30.8103 67.2771 33.668 67.2771L72.1337 67.3056C74.9914 67.3056 77.3089 64.9834 77.3089 62.1111L77.3799 15.8029L68.7854 7.02858ZM68.7854 7.02858L68.7854 15.8038H77.3089L68.7854 7.02858Z"
stroke="#121111" stroke-width="3" stroke-miterlimit="10"
stroke-linecap="round" stroke-linejoin="round"/>
<path d="M45.1401 22.5937H68.0201" stroke="#121111" stroke-width="3"
stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M69.5 20.8335H35.5V27.8335H69.5V20.8335Z" fill="#FFF5FF"
stroke="#121111" stroke-width="2" stroke-miterlimit="10"
stroke-linecap="round" stroke-linejoin="round"/>
<circle cx="67.5" cy="54" r="15.5" fill="#FFE8CE" stroke="#121111"
stroke-width="3"/>
<rect x="65.5" y="43" width="4" height="16" rx="2" fill="black"/>
<circle cx="67.5" cy="63" r="2" fill="black"/>
</svg>
</td>
</tr>
<tr>
<td>computer-text</td>
<td>
Expand Down
Loading