use of com.jeesuite.common.model.AuthUser in project jeesuite-libs by vakinge.
the class ActionLogCollector method onRequestStart.
public static ActionLog onRequestStart(HttpServletRequest request) {
ActionLog actionLog = new ActionLog();
actionLog.setAppId(GlobalRuntimeContext.SYSTEM_ID);
actionLog.setRequestAt(new Date());
actionLog.setRequestIp(IpUtils.getIpAddr(request));
actionLog.setActionKey(String.format("%s_%s", request.getMethod(), request.getRequestURI()));
actionLog.setModuleId(GlobalRuntimeContext.APPID);
actionLog.setRequestId(CurrentRuntimeContext.getRequestId());
actionLog.setTenantId(CurrentRuntimeContext.getTenantId());
actionLog.setClientType(CurrentRuntimeContext.getClientType());
AuthUser currentUser = CurrentRuntimeContext.getCurrentUser();
if (currentUser != null) {
actionLog.setUserId(currentUser.getId());
actionLog.setUserName(currentUser.getName());
}
if (context.get() == null) {
context.set(actionLog);
}
return actionLog;
}
use of com.jeesuite.common.model.AuthUser in project jeesuite-libs by vakinge.
the class CurrentRuntimeContext method getCurrentUser.
public static AuthUser getCurrentUser() {
AuthUser user = ThreadLocalContext.get(CustomRequestHeaders.HEADER_AUTH_USER);
if (user == null) {
HttpServletRequest request = getRequest();
if (request == null)
return null;
String headerString = request.getHeader(CustomRequestHeaders.HEADER_AUTH_USER);
user = AuthUser.decode(headerString);
if (user != null) {
ThreadLocalContext.set(CustomRequestHeaders.HEADER_AUTH_USER, user);
}
}
return user;
}
use of com.jeesuite.common.model.AuthUser in project jeesuite-libs by vakinge.
the class MockLoginUserInterceptor method preHandle.
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
if (CurrentRuntimeContext.getCurrentUser() == null) {
AuthUser authUser = new AuthUser();
authUser.setId("1");
authUser.setName("admin");
CurrentRuntimeContext.setAuthUser(authUser);
}
return true;
}
Aggregations