コード例 #1
0
  public void layout() {
    super.layout();

    username = getPageParameters().getString("username");
    if (username == null) {
      username = getSession().getUser().getUsername();
    }

    org.headsupdev.agile.api.User user = getSecurityManager().getUserByUsername(username);
    if (user == null || user.equals(HeadsUpSession.ANONYMOUS_USER)) {
      notFoundError();
      return;
    }

    boolean me = username.equals(getSession().getUser().getUsername());
    if (!me) {
      requirePermission(new AdminPermission());
    }
    addLink(new BookmarkableMenuLink(getPageClass("account"), getPageParameters(), "view"));
    addLink(
        new BookmarkableMenuLink(
            getPageClass("subscriptions"), getPageParameters(), "subscriptions"));

    add(new ChangePasswordForm("edituser", user, me));
  }
コード例 #2
0
    public void onSubmit() {
      Session session = ((HibernateStorage) getStorage()).getHibernateSession();
      Transaction tx = session.beginTransaction();
      user = (org.headsupdev.agile.api.User) session.merge(user);

      ((StoredUser) user).setPassword(pass1);
      if (me) {
        ((HeadsUpSession) getSession()).setUser(user);
      }

      session.update(user);
      tx.commit();

      PageParameters params = new PageParameters();
      params.add("username", user.getUsername());
      setResponsePage(getPageClass("account"), params);
    }