Search in sources :

Example 66 with LogOperate

use of com.publiccms.entities.log.LogOperate in project PublicCMS-preview by sanluan.

the class UserController method changePassword.

/**
 * @param oldpassword
 * @param password
 * @param repassword
 * @param returnUrl
 * @param request
 * @param session
 * @param response
 * @param model
 * @return view name
 */
@RequestMapping(value = "changePassword", method = RequestMethod.POST)
public String changePassword(String oldpassword, String password, String repassword, String returnUrl, HttpServletRequest request, HttpSession session, HttpServletResponse response, ModelMap model) {
    SysSite site = getSite(request);
    if (CommonUtils.empty(returnUrl)) {
        returnUrl = site.getDynamicPath();
    }
    SysUser user = getUserFromSession(session);
    if (ControllerUtils.verifyNotEmpty("user", user, model) || ControllerUtils.verifyNotEmpty("password", password, model) || ControllerUtils.verifyNotEquals("repassword", password, repassword, model) || ControllerUtils.verifyNotEquals("password", user.getPassword(), VerificationUtils.md5Encode(oldpassword), model)) {
        return REDIRECT + returnUrl;
    } else {
        Cookie userCookie = RequestUtils.getCookie(request.getCookies(), CommonConstants.getCookiesUser());
        if (null != userCookie && CommonUtils.notEmpty(userCookie.getValue())) {
            String value = userCookie.getValue();
            if (null != value) {
                String[] userData = value.split(CommonConstants.getCookiesUserSplit());
                if (userData.length > 1) {
                    sysUserTokenService.delete(userData[1]);
                }
            }
        }
        clearUserToSession(request.getContextPath(), session, response);
        service.updatePassword(user.getId(), VerificationUtils.md5Encode(password));
        model.addAttribute(MESSAGE, SUCCESS);
        logOperateService.save(new LogOperate(site.getId(), user.getId(), LogLoginService.CHANNEL_WEB, "changepassword", RequestUtils.getIpAddress(request), CommonUtils.getDate(), user.getPassword()));
        return REDIRECT + returnUrl;
    }
}
Also used : Cookie(javax.servlet.http.Cookie) LogOperate(com.publiccms.entities.log.LogOperate) SysUser(com.publiccms.entities.sys.SysUser) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 67 with LogOperate

use of com.publiccms.entities.log.LogOperate in project PublicCMS-preview by sanluan.

the class SysConfigAdminController method save.

/**
 * @param entity
 * @param configCode
 * @param request
 * @param session
 * @return view name
 */
@RequestMapping("save")
public String save(@ModelAttribute SysConfig entity, String configCode, HttpServletRequest request, HttpSession session) {
    SysSite site = getSite(request);
    if (CommonUtils.notEmpty(configCode)) {
        Map<String, SysConfig> map = configComponent.getMap(site);
        map.remove(configCode);
        map.put(entity.getCode(), entity);
        configComponent.save(site, map);
        logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "update.config", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
    } else {
        Map<String, SysConfig> map = configComponent.getMap(site);
        map.put(entity.getCode(), entity);
        configComponent.save(site, map);
        logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "save.config", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
    }
    return TEMPLATE_DONE;
}
Also used : SysConfig(com.publiccms.views.pojo.entities.SysConfig) LogOperate(com.publiccms.entities.log.LogOperate) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 68 with LogOperate

use of com.publiccms.entities.log.LogOperate in project PublicCMS-preview by sanluan.

the class SysDeptAdminController method enable.

/**
 * @param id
 * @param request
 * @param session
 * @param model
 * @return view name
 */
@RequestMapping(value = "enableUser", method = RequestMethod.POST)
public String enable(Long id, HttpServletRequest request, HttpSession session, ModelMap model) {
    if (ControllerUtils.verifyEquals("admin.operate", getAdminFromSession(session).getId(), id, model)) {
        return TEMPLATE_ERROR;
    }
    SysUser entity = userService.getEntity(id);
    if (null != entity) {
        SysSite site = getSite(request);
        SysDept dept = service.getEntity(entity.getDeptId());
        SysUser admin = getAdminFromSession(session);
        if (ControllerUtils.verifyNotEquals("siteId", site.getId(), entity.getSiteId(), model) || ControllerUtils.verifyNotEmpty("deptId", dept, model) || ControllerUtils.verifyNotEquals("userId", dept.getUserId(), admin.getId(), model)) {
            return TEMPLATE_ERROR;
        }
        userService.updateStatus(id, false);
        logOperateService.save(new LogOperate(site.getId(), admin.getId(), LogLoginService.CHANNEL_WEB_MANAGER, "enable.user", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
    }
    return TEMPLATE_DONE;
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) SysUser(com.publiccms.entities.sys.SysUser) SysDept(com.publiccms.entities.sys.SysDept) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 69 with LogOperate

use of com.publiccms.entities.log.LogOperate in project PublicCMS-preview by sanluan.

the class SysDeptAdminController method delete.

/**
 * @param id
 * @param request
 * @param session
 * @return view name
 */
@RequestMapping("delete")
public String delete(Integer id, HttpServletRequest request, HttpSession session) {
    SysSite site = getSite(request);
    List<Integer> list = service.delete(site.getId(), id);
    if (0 < list.size()) {
        for (Integer childId : list) {
            sysDeptCategoryService.delete(childId, null);
            sysDeptPageService.delete(childId, null);
        }
        logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "delete.dept", RequestUtils.getIpAddress(request), CommonUtils.getDate(), id.toString()));
    }
    return TEMPLATE_DONE;
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 70 with LogOperate

use of com.publiccms.entities.log.LogOperate in project PublicCMS-preview by sanluan.

the class SysDeptAdminController method saveUser.

/**
 * @param entity
 * @param repassword
 * @param roleIds
 * @param request
 * @param session
 * @param model
 * @return view name
 */
@RequestMapping("saveUser")
public String saveUser(SysUser entity, String repassword, Integer[] roleIds, HttpServletRequest request, HttpSession session, ModelMap model) {
    SysSite site = getSite(request);
    entity.setName(StringUtils.trim(entity.getName()));
    entity.setNickName(StringUtils.trim(entity.getNickName()));
    entity.setPassword(StringUtils.trim(entity.getPassword()));
    repassword = StringUtils.trim(repassword);
    SysDept dept = service.getEntity(entity.getDeptId());
    SysUser admin = getAdminFromSession(session);
    if (ControllerUtils.verifyNotEmpty("username", entity.getName(), model) || ControllerUtils.verifyNotEmpty("deptId", dept, model) || ControllerUtils.verifyNotEquals("userId", dept.getUserId(), admin.getId(), model) || ControllerUtils.verifyNotEquals("siteId", site.getId(), dept.getSiteId(), model) || ControllerUtils.verifyNotEmpty("nickname", entity.getNickName(), model) || verifyNotUserName("username", entity.getName(), model) || verifyNotNickName("nickname", entity.getNickName(), model)) {
        return TEMPLATE_ERROR;
    }
    entity.setSuperuserAccess(true);
    entity.setRoles(arrayToCommaDelimitedString(roleIds));
    if (null != entity.getId()) {
        SysUser oldEntity = userService.getEntity(entity.getId());
        if (null == oldEntity || ControllerUtils.verifyNotEquals("siteId", site.getId(), oldEntity.getSiteId(), model)) {
            return TEMPLATE_ERROR;
        }
        SysUser user = userService.getEntity(entity.getId());
        if ((!user.getName().equals(entity.getName()) && ControllerUtils.verifyHasExist("username", userService.findByName(site.getId(), entity.getName()), model)) || (!user.getNickName().equals(entity.getNickName()) && ControllerUtils.verifyHasExist("nickname", userService.findByNickName(site.getId(), entity.getNickName()), model))) {
            return TEMPLATE_ERROR;
        }
        if (CommonUtils.notEmpty(entity.getPassword())) {
            if (ControllerUtils.verifyNotEquals("repassword", entity.getPassword(), repassword, model)) {
                return TEMPLATE_ERROR;
            }
            entity.setPassword(VerificationUtils.md5Encode(entity.getPassword()));
        } else {
            entity.setPassword(user.getPassword());
            if (CommonUtils.empty(entity.getEmail()) || !entity.getEmail().equals(user.getEmail())) {
                entity.setEmailChecked(false);
            }
        }
        entity = userService.update(entity.getId(), entity, userIgnoreProperties);
        if (null != entity) {
            roleUserService.dealRoleUsers(entity.getId(), roleIds);
            logOperateService.save(new LogOperate(site.getId(), admin.getId(), LogLoginService.CHANNEL_WEB_MANAGER, "update.user", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
        }
    } else {
        if (ControllerUtils.verifyNotEmpty("password", entity.getPassword(), model) || ControllerUtils.verifyNotEquals("repassword", entity.getPassword(), repassword, model) || ControllerUtils.verifyHasExist("username", userService.findByName(site.getId(), entity.getName()), model)) {
            return TEMPLATE_ERROR;
        }
        entity.setDeptId(dept.getId());
        entity.setSiteId(site.getId());
        entity.setPassword(VerificationUtils.md5Encode(entity.getPassword()));
        userService.save(entity);
        if (CommonUtils.notEmpty(roleIds)) {
            for (Integer roleId : roleIds) {
                roleUserService.save(new SysRoleUser(new SysRoleUserId(roleId, entity.getId())));
            }
        }
        logOperateService.save(new LogOperate(site.getId(), admin.getId(), LogLoginService.CHANNEL_WEB_MANAGER, "save.user", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
    }
    return TEMPLATE_DONE;
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) SysUser(com.publiccms.entities.sys.SysUser) SysDept(com.publiccms.entities.sys.SysDept) SysRoleUserId(com.publiccms.entities.sys.SysRoleUserId) SysSite(com.publiccms.entities.sys.SysSite) SysRoleUser(com.publiccms.entities.sys.SysRoleUser) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

LogOperate (com.publiccms.entities.log.LogOperate)117 SysSite (com.publiccms.entities.sys.SysSite)117 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)115 SysUser (com.publiccms.entities.sys.SysUser)15 IOException (java.io.IOException)13 CmsContent (com.publiccms.entities.cms.CmsContent)9 File (java.io.File)9 MultipartFile (org.springframework.web.multipart.MultipartFile)8 CmsCategory (com.publiccms.entities.cms.CmsCategory)7 TemplateException (freemarker.template.TemplateException)7 SysDept (com.publiccms.entities.sys.SysDept)6 SysTask (com.publiccms.entities.sys.SysTask)6 CmsPageMetadata (com.publiccms.views.pojo.entities.CmsPageMetadata)5 CmsPlaceMetadata (com.publiccms.views.pojo.entities.CmsPlaceMetadata)5 CmsPlace (com.publiccms.entities.cms.CmsPlace)4 CmsWord (com.publiccms.entities.cms.CmsWord)4 SysDomain (com.publiccms.entities.sys.SysDomain)4 SysRoleUser (com.publiccms.entities.sys.SysRoleUser)4 CmsModel (com.publiccms.views.pojo.entities.CmsModel)4 CmsCategoryType (com.publiccms.entities.cms.CmsCategoryType)3