コード例 #1
0
ファイル: UserSetHandler.java プロジェクト: iisihub/CAP
 public Result changePassword(Request request) {
   String password = request.get("password");
   String newPwd = request.get("newPwd");
   String confirm = request.get("confirm");
   String userId = CapSecurityContext.getUserId();
   if (passwordService.validatePassword(userId, password)) {
     passwordService.checkPasswordRule(userId, newPwd, confirm, false);
     passwordService.changeUserPassword(userId, newPwd);
   } else {
     throw new CapMessageException(CapAppContext.getMessage("error.009"), getClass());
   }
   return new AjaxFormResult();
 }
コード例 #2
0
ファイル: UserSetHandler.java プロジェクト: iisihub/CAP
 public Result add(Request request) {
   String code = request.get("code");
   DefaultUser user = userService.findUserByUserCode(code);
   if (user != null) {
     throw new CapMessageException(
         CapAppContext.getMessage("users.exist", new Object[] {code}), getClass());
   }
   String name = request.get("name");
   String password = request.get("password");
   String confirm = request.get("confirm");
   passwordService.checkPasswordRule(code, password, confirm, true);
   String email = request.get("email");
   String[] roleCodes = request.getParamsAsStringArray("roleCodes");
   userService.createUser(code, name, password, email, roleCodes);
   return new AjaxFormResult();
 }
コード例 #3
0
ファイル: UserSetHandler.java プロジェクト: iisihub/CAP
 public Result modify(Request request) {
   String oid = request.get("oid");
   String code = request.get("code");
   String password = request.get("password");
   String confirm = request.get("confirm");
   boolean reset = !StringUtils.isBlank(password);
   if (reset) {
     // 代表要修改密碼
     passwordService.checkPasswordRule(code, password, confirm, true);
   }
   DefaultUser user = userService.findUserByUserCode(code);
   if (user != null && !user.getOid().equals(oid)) {
     throw new CapMessageException(
         CapAppContext.getMessage("users.exist", new Object[] {code}), getClass());
   }
   String name = request.get("name");
   String email = request.get("email");
   String[] roleCodes = request.getParamsAsStringArray("roleCodes");
   userService.updateUserByOid(oid, code, name, reset, password, email, roleCodes);
   return new AjaxFormResult();
 }