Exemple #1
0
 public boolean changePassword(String userId, String oldPassword, String newPassword) {
   if (identityService.checkPassword(userId, oldPassword)) {
     User user = identityService.createUserQuery().userId(userId).singleResult();
     user.setPassword(newPassword);
     identityService.saveUser(user);
     Log.writeLog("修改了登录密码");
     return true;
   } else return false;
 }
Exemple #2
0
 public String validUser(String userId, String password, HttpSession httpSession) {
   if (!identityService.checkPassword(userId, password)) {
     System.out.println("false");
     return "false";
   } else {
     String userName =
         identityService.createUserQuery().userId(userId).singleResult().getFirstName();
     String groupName =
         identityService
             .createGroupQuery()
             .groupMember(userId)
             .groupType("role")
             .singleResult()
             .getName();
     System.out.println(httpSession.getId());
     httpSession.setAttribute("userId", userId);
     httpSession.setAttribute("groupName", groupName);
     httpSession.setAttribute("userName", userName);
     Log.writeLog("登录成功");
     return "true";
   }
 }
Exemple #3
0
 public void cleanSession(HttpSession httpSession) {
   Log.writeLog("退出登录");
   httpSession.removeAttribute("userId");
   httpSession.removeAttribute("groupName");
   httpSession.removeAttribute("userName");
 }