@RequestMapping("/change_password")
  public String changePassword(HttpServletRequest request) {
    Application application = ApplicationResolver.INSTANCE.getApplication(request);
    Account account = AccountResolver.INSTANCE.getAccount(request);

    if (account != null && application != null) {
      String email = account.getEmail();
      PasswordResetToken token = application.sendPasswordResetEmail(email);
      return "redirect:/change?sptoken=" + token.getValue();
    }
    return "redirect:/login?next=/change_password";
  }
Exemplo n.º 2
0
  @RequestMapping("/edit")
  public String gatherInformation(HttpServletRequest servletRequest, Model model) {
    if (AccountResolver.INSTANCE.hasAccount(servletRequest)) {
      // a known user has authenticated previously - get the user identity:
      Account account = AccountResolver.INSTANCE.getRequiredAccount(servletRequest);
      Person person = repository.findById(Person.makeId(account.getEmail()));

      if (person == null) {
        person = new Person(account);
        System.out.println(person);
      }

      model.addAttribute("person", person);

      System.out.println(
          person.getIsMarried()
              + "  "
              + person.getSpouse()
              + "  "
              + repository.findById(person.getSpouse()));
      if (person.getIsMarried()) {
        Person spouse = repository.findById(person.getSpouse());
        AccessRequest spouseReq =
            accessRequestRepository.findById(AccessRequest.makeId(spouse.getId(), person.getId()));
        System.out.println(spouseReq);

        model.addAttribute("spouseReq", spouseReq);
        model.addAttribute("spouse", spouse);
      }

      if (person.hasChildren()) {
        // Do nothing for right now
      }
    } else {
      // the current user is unknown - either unauthenticated or a guest.
      // Should redirect
    }

    return "gather_information";
  }