class MonitoringOfficerRegistrationController {

    @GetMapping("/{inviteHash}/register")
    public String openInvite(@PathVariable("inviteHash") String inviteHash,
                             Model model,
                             HttpServletRequest request,
                             @ModelAttribute("form") RegistrationForm form,
                             UserResource loggedInUser) {

        if (loggedInUser != null) {
            if (!competitionSetupMonitoringOfficerRestService.getMonitoringOfficerInvite(inviteHash).getSuccess().getEmail().equalsIgnoreCase(loggedInUser.getEmail())) {
                return "registration/error";
            }
        }

        MonitoringOfficerInviteResource monitoringOfficerInviteResource = competitionSetupMonitoringOfficerRestService.openMonitoringOfficerInvite(inviteHash).getSuccess();
        form.setEmail(monitoringOfficerInviteResource.getEmail());
        model.addAttribute("model", RegistrationViewModelBuilder.aRegistrationViewModel().withPhoneRequired(true).withTermsRequired(false).withInvitee(true).build());
        return "registration/register";
    }

}