|
|
@@ -64,28 +64,30 @@ public class MobileAuthenticationInterceptor implements ServerInterceptor {
|
|
|
if (headers.containsKey(AUTH_HEADER_KEY)) {
|
|
|
TokenDTO tokenDTO = tokenApi.findByPrimaryKey(headers.get(AUTH_HEADER_KEY));
|
|
|
if (null != tokenDTO) {
|
|
|
- try {
|
|
|
- // token信息放在当前线程
|
|
|
- TokenHolder.set(tokenDTO);
|
|
|
- // 用户信息放在当前线程
|
|
|
- AccountDTO accountDTO = accountApi.findByPrimaryKey(tokenDTO.getAccountId());
|
|
|
- AccountHolder.set(accountDTO);
|
|
|
- // 企业信息放在当前线程
|
|
|
- if (null != tokenDTO.getCompanyId()) {
|
|
|
- CompanyDTO companyDTO = companyApi.findByPrimaryKey(tokenDTO.getCompanyId());
|
|
|
- CompanyHolder.set(companyDTO);
|
|
|
- }
|
|
|
- // 设备信息放在当前线程
|
|
|
- DeviceInfoDTO deviceInfoDTO = deviceInfoApi.findByAccountId(tokenDTO.getAccountId());
|
|
|
- DeviceInfoHolder.set(deviceInfoDTO);
|
|
|
-
|
|
|
- return next.startCall(call, headers);
|
|
|
- } finally {
|
|
|
- TokenHolder.clear();
|
|
|
- AccountHolder.clear();
|
|
|
- CompanyHolder.clear();
|
|
|
- DeviceInfoHolder.clear();
|
|
|
+ // token信息放在当前线程
|
|
|
+ TokenHolder.set(tokenDTO);
|
|
|
+ // 用户信息放在当前线程
|
|
|
+ AccountDTO accountDTO = accountApi.findByPrimaryKey(tokenDTO.getAccountId());
|
|
|
+ AccountHolder.set(accountDTO);
|
|
|
+ // 企业信息放在当前线程
|
|
|
+ if (null != tokenDTO.getCompanyId()) {
|
|
|
+ CompanyDTO companyDTO = companyApi.findByPrimaryKey(tokenDTO.getCompanyId());
|
|
|
+ CompanyHolder.set(companyDTO);
|
|
|
}
|
|
|
+ // 设备信息放在当前线程
|
|
|
+ DeviceInfoDTO deviceInfoDTO = deviceInfoApi.findByAccountId(tokenDTO.getAccountId());
|
|
|
+ DeviceInfoHolder.set(deviceInfoDTO);
|
|
|
+
|
|
|
+ return next.startCall(new ForwardingServerCall.SimpleForwardingServerCall<ReqT, RespT>(call) {
|
|
|
+ @Override
|
|
|
+ public void close(Status status, Metadata trailers) {
|
|
|
+ super.close(status, trailers);
|
|
|
+ TokenHolder.clear();
|
|
|
+ AccountHolder.clear();
|
|
|
+ CompanyHolder.clear();
|
|
|
+ DeviceInfoHolder.clear();
|
|
|
+ }
|
|
|
+ }, headers);
|
|
|
} else {
|
|
|
logger.error("Authentication Expired On Call {}", method);
|
|
|
call.close(Status.UNAUTHENTICATED.withDescription("会话过期,请重新登录"), headers);
|