Exemple #1
0
  public void doLogin(
      @FormGroup("login") User user,
      @FormField(name = "loginError", group = "login") CustomErrors err,
      @Param("Done") String url,
      Navigator nav,
      HttpSession session,
      ParameterParser params)
      throws Exception {

    user = userService.login(user.getName(), SecurityUtils.getPassword(user.getPassword()));

    if (user != null) {
      // 在session中创建User对象
      session.setAttribute(WebConstant.USER_SESSION_KEY, user);

      // 跳转到return页面
      if (null == url) {
        nav.redirectTo(WebConstant.CHANNEL_LIST_LINK);
      } else {
        nav.redirectToLocation(url);
      }

    } else {
      err.setMessage("invalidUserOrPassword");
    }
  }
Exemple #2
0
  public void doLogout(HttpSession session, Navigator nav, ParameterParser params)
      throws Exception {
    // 清除session中的user
    session.removeAttribute(WebConstant.USER_SESSION_KEY);

    // 跳转到return页面
    nav.redirectTo(WebConstant.OTTER_LOGIN_LINK);
  }
Exemple #3
0
 public void doAdd(
     @FormGroup("addUserInfo") Group userInfo,
     Navigator nav,
     @FormField(name = "formUserError", group = "addUserInfo") CustomErrors err) {
   User user = new User();
   userInfo.setProperties(user);
   user.setPassword(SecurityUtils.getPassword(user.getPassword()));
   try {
     userService.createUser(user);
   } catch (RepeatConfigureException rce) {
     err.setMessage("invalidUser");
     return;
   }
   nav.redirectTo(WebConstant.USER_MANAGER_LINK);
 }
 public void doRegister(@FormGroup("register") Visitor visitor, Navigator nav) {
   String name = visitor.getName();
   nav.redirectTo("app1Link").withTarget("form/welcome").withParameter("name", name);
 }