use of com.ngtesting.platform.vo.UserVo in project ngtesting-platform by aaronchen2k.
the class AccountAction method changePassword.
@RequestMapping(value = "changePassword", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> changePassword(HttpServletRequest request, @RequestBody JSONObject json) {
Map<String, Object> ret = new HashMap<String, Object>();
UserVo vo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
String oldPassword = json.getString("oldPassword");
String password = json.getString("password");
boolean success = accountService.changePasswordPers(vo.getId(), oldPassword, password);
int code = success ? RespCode.SUCCESS.getCode() : RespCode.BIZ_FAIL.getCode();
ret.put("code", code);
return ret;
}
use of com.ngtesting.platform.vo.UserVo in project ngtesting-platform by aaronchen2k.
the class AccountAction method logout.
@AuthPassport(validate = true)
@RequestMapping(value = "logout", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> logout(HttpServletRequest request, @RequestBody JSONObject json) {
Map<String, Object> ret = new HashMap<String, Object>();
UserVo vo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
if (vo == null) {
ret.put("code", RespCode.BIZ_FAIL.getCode());
ret.put("msg", "您不在登录状态");
return ret;
}
TestUser user = accountService.logoutPers(vo.getEmail());
if (user != null) {
request.getSession().removeAttribute(Constant.HTTP_SESSION_USER_KEY);
ret.put("code", RespCode.SUCCESS.getCode());
} else {
ret.put("code", RespCode.BIZ_FAIL.getCode());
ret.put("msg", "登出失败");
}
return ret;
}
use of com.ngtesting.platform.vo.UserVo in project ngtesting-platform by aaronchen2k.
the class AlertAction method markAllRead.
@AuthPassport(validate = true)
@RequestMapping(value = "markAllRead", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> markAllRead(HttpServletRequest request, @RequestBody JSONObject json) {
Map<String, Object> ret = new HashMap<String, Object>();
UserVo userVo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
alertService.markAllReadPers(json.getString("ids"));
optFacade.opt(WsConstant.WS_TODO, userVo.getId().toString());
ret.put("code", Constant.RespCode.SUCCESS.getCode());
return ret;
}
use of com.ngtesting.platform.vo.UserVo in project ngtesting-platform by aaronchen2k.
the class WebSocketHandshakeInterceptor method beforeHandshake.
@Override
public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Map<String, Object> attributes) throws Exception {
ApplicationScopeBean scopeBean = SpringContextHolder.getBean(ApplicationScopeBean.class);
if (request instanceof ServletServerHttpRequest) {
ServletServerHttpRequest servletRequest = (ServletServerHttpRequest) request;
HttpSession httpSession = servletRequest.getServletRequest().getSession(true);
String test = (String) httpSession.getAttribute("TEST");
UserVo user = null;
if (httpSession.getAttribute(Constant.HTTP_SESSION_USER_KEY) != null) {
user = (UserVo) httpSession.getAttribute(Constant.HTTP_SESSION_USER_KEY);
}
if (user != null) {
attributes.put(WsConstant.WS_USER_KEY, user.getId().toString());
attributes.put("somthing", "somthing");
return true;
}
}
return false;
}
use of com.ngtesting.platform.vo.UserVo in project ngtesting-platform by aaronchen2k.
the class EnvAction method get.
@AuthPassport(validate = true)
@RequestMapping(value = "get", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> get(HttpServletRequest request, @RequestBody JSONObject json) {
Map<String, Object> ret = new HashMap<String, Object>();
UserVo userVo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
Long id = json.getLong("id");
TestEnvVo vo = envService.getById(id);
ret.put("data", vo);
ret.put("code", Constant.RespCode.SUCCESS.getCode());
return ret;
}
Aggregations