Beispiel #1
0
 @Before
 static void setConnectedUser() {
   if (Security.isConnected()) {
     User user = User.find("byUsername", Security.connected()).first();
     if (!user.isAdmin) {
       flash.error(Messages.get("UserIsNotAuthorized"));
       Application.index();
     }
   }
 }
Beispiel #2
0
  public static void activate(String uuid) {

    Logger.info("用户开始进行激活,uuid" + uuid);
    User user = User.find("uuid", uuid).first();
    Logger.info("start activate:" + user.activated + "id:" + user.id);
    if (user != null) {
      // 激活成功
      user.activated = true;
      user.save();
      Logger.info("user id:" + user.id);
      render("@activatesuccess");

    } else {
      Application.index();
    }
  }
Beispiel #3
0
  public static void isLogin(String email, String password) {
    User user = User.find("byEmailAndPasswordAndDeleted", email, password, false).first();
    // 用户名or 密码错误
    if (user == null) {
      render("@login");
    } else {

      // 未激活
      if (user.activated == false) {
        session.put("user", user.email);
        // 跳至激活页面
        render("@notactivate", email);
      }

      session.put("user", user.email);
      Application.index();
    }
  }
Beispiel #4
0
 public static void logout() {
   session.clear();
   Application.index();
 }