class AssessorRegistrationController {

    @GetMapping(value = "/{inviteHash}/register/account-created")
    public String accountCreated(Model model, @PathVariable("inviteHash") String inviteHash, UserResource loggedInUser) {
        boolean userIsLoggedIn = loggedInUser != null;

        // the user is already logged in, take them back to the invite
        if (userIsLoggedIn) {
            return format("redirect:/invite/competition/%s", inviteHash);
        }

        return competitionInviteRestService.checkExistingUser(inviteHash).andOnSuccessReturn(userExists -> {
            if (!userExists) {
                // reached here without creating an assessor, redirect back to the invite
                return format("redirect:/invite/competition/%s", inviteHash);
            }
            else {
                model.addAttribute("competitionInviteHash", inviteHash);
                return "registration/account-created";
            }
        }).getSuccess();
    }

}