@Override public User checkLogin(String account, String password) { password = PasswordMD.md5(password); User u = userDao.queryByAccount(account); if (u == null) { u = userDao.queryByEnEmail(account); } if (u != null && password.equals(u.getPassword())) { return u; } else { throw new ServiceException(ErrService.UserS.ACC_109, "用户账号或者密码错误"); } }
@Override public void editUserPasswore(Long userId, String oldPsw, String newPsw) { // 验证密码格式 if (!StringUtil.match(newPsw, "^.{6,20}$")) { throw new ServiceException(ErrService.UserS.ACC_107, "密码:“" + newPsw + "”格式错误。"); } // 密码MD5加密 oldPsw = PasswordMD.md5(oldPsw); User user = userDao.queryById(userId); if (!user.getPassword().equals(oldPsw)) { throw new ServiceException(ErrService.UserS.ACC_103, "用户:“" + userId + "”原始密码错误。"); } newPsw = PasswordMD.md5(newPsw); userDao.updatePsw(userId, newPsw); }