Search in sources :

Example 26 with SysUser

use of com.publiccms.entities.sys.SysUser in project PublicCMS-preview by sanluan.

the class SysUserAdminController method enable.

/**
 * @param id
 * @param request
 * @param session
 * @param model
 * @return view name
 */
@RequestMapping(value = "enable", 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 = service.getEntity(id);
    if (null != entity) {
        SysSite site = getSite(request);
        if (ControllerUtils.verifyNotEquals("siteId", site.getId(), entity.getSiteId(), model)) {
            return TEMPLATE_ERROR;
        }
        service.updateStatus(id, false);
        logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).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) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 27 with SysUser

use of com.publiccms.entities.sys.SysUser in project PublicCMS-preview by sanluan.

the class SysUserAdminController method disable.

/**
 * @param id
 * @param request
 * @param session
 * @param model
 * @return view name
 */
@RequestMapping(value = "disable", method = RequestMethod.POST)
public String disable(Long id, HttpServletRequest request, HttpSession session, ModelMap model) {
    if (ControllerUtils.verifyEquals("admin.operate", getAdminFromSession(session).getId(), id, model)) {
        return TEMPLATE_ERROR;
    }
    SysUser entity = service.getEntity(id);
    if (null != entity) {
        SysSite site = getSite(request);
        if (ControllerUtils.verifyNotEquals("siteId", site.getId(), entity.getSiteId(), model)) {
            return TEMPLATE_ERROR;
        }
        service.updateStatus(id, true);
        logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "disable.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) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 28 with SysUser

use of com.publiccms.entities.sys.SysUser in project PublicCMS-preview by sanluan.

the class WebContextInterceptor method preHandle.

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws ServletException {
    HttpSession session = request.getSession();
    SysSite site = siteComponent.getSite(request.getServerName());
    SysUser user = initUser(AbstractController.getUserFromSession(session), LogLoginService.CHANNEL_WEB, CommonConstants.getCookiesUser(), site, request, response);
    if (null != user) {
        Date date = AbstractController.getUserTimeFromSession(session);
        if (null == date || date.before(DateUtils.addSeconds(new Date(), -30))) {
            SysUser entity = sysUserService.getEntity(user.getId());
            if (null != entity && !entity.isDisabled() && null != site && !site.isDisabled() && site.getId() == entity.getSiteId()) {
                user.setName(entity.getName());
                user.setNickName(entity.getNickName());
                user.setEmail(entity.getEmail());
                user.setEmailChecked(entity.isEmailChecked());
                user.setSuperuserAccess(entity.isSuperuserAccess());
                AbstractController.setUserToSession(session, user);
            } else {
                Cookie userCookie = RequestUtils.getCookie(request.getCookies(), CommonConstants.getCookiesUser());
                if (null != userCookie && StringUtils.isNotBlank(userCookie.getValue())) {
                    String value = userCookie.getValue();
                    if (null != value) {
                        String[] userData = value.split(CommonConstants.getCookiesUserSplit());
                        if (userData.length > 1) {
                            sysUserTokenService.delete(userData[1]);
                        }
                    }
                }
                AbstractController.clearUserToSession(request.getContextPath(), session, response);
            }
        }
    }
    localeChangeInterceptor.preHandle(request, response, handler);
    return true;
}
Also used : Cookie(javax.servlet.http.Cookie) SysUser(com.publiccms.entities.sys.SysUser) HttpSession(javax.servlet.http.HttpSession) Date(java.util.Date) SysSite(com.publiccms.entities.sys.SysSite)

Example 29 with SysUser

use of com.publiccms.entities.sys.SysUser in project PublicCMS-preview by sanluan.

the class AbstractAppDirective method execute.

@Override
public void execute(RenderHandler handler) throws IOException, Exception {
    SysApp app = null;
    SysUser user = null;
    if (needAppToken() && (null == (app = getApp(handler)) || CommonUtils.empty(app.getAuthorizedApis()) || !ArrayUtils.contains(StringUtils.split(app.getAuthorizedApis(), COMMA_DELIMITED), getName()))) {
        if (null == app) {
            handler.put("error", ApiController.NEED_APP_TOKEN).render();
        } else {
            handler.put("error", ApiController.UN_AUTHORIZED).render();
        }
    } else if (needUserToken() && null == (user = getUser(handler))) {
        handler.put("error", ApiController.NEED_LOGIN).render();
    } else {
        execute(handler, app, user);
        handler.render();
    }
}
Also used : SysApp(com.publiccms.entities.sys.SysApp) SysUser(com.publiccms.entities.sys.SysUser)

Aggregations

SysUser (com.publiccms.entities.sys.SysUser)29 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)23 SysSite (com.publiccms.entities.sys.SysSite)21 LogOperate (com.publiccms.entities.log.LogOperate)15 SysDept (com.publiccms.entities.sys.SysDept)5 HttpParameterHandler (com.publiccms.common.handler.HttpParameterHandler)3 CmsContent (com.publiccms.entities.cms.CmsContent)3 CmsPlace (com.publiccms.entities.cms.CmsPlace)3 SysRoleUser (com.publiccms.entities.sys.SysRoleUser)3 SysRoleUserId (com.publiccms.entities.sys.SysRoleUserId)3 SysUserToken (com.publiccms.entities.sys.SysUserToken)3 CmsPlaceMetadata (com.publiccms.views.pojo.entities.CmsPlaceMetadata)3 Cookie (javax.servlet.http.Cookie)3 CmsCategory (com.publiccms.entities.cms.CmsCategory)2 CmsCategoryModel (com.publiccms.entities.cms.CmsCategoryModel)2 CmsCategoryModelId (com.publiccms.entities.cms.CmsCategoryModelId)2 LogLogin (com.publiccms.entities.log.LogLogin)2 SysExtendField (com.publiccms.entities.sys.SysExtendField)2 CmsModel (com.publiccms.views.pojo.entities.CmsModel)2 ExtendField (com.publiccms.views.pojo.entities.ExtendField)2