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;
}
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;
}
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;
}
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();
}
}
Aggregations