From 576f7eefe00832b8a7f7750cfd0ee6975bcf6acf Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Mon, 15 Jun 2020 10:16:02 +0800
Subject: [PATCH] 20200615 代码提交
---
src/main/java/com/xcong/excoin/common/LoginUserUtils.java | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/common/LoginUserUtils.java b/src/main/java/com/xcong/excoin/common/LoginUserUtils.java
index 0c24019..8f2400a 100644
--- a/src/main/java/com/xcong/excoin/common/LoginUserUtils.java
+++ b/src/main/java/com/xcong/excoin/common/LoginUserUtils.java
@@ -3,7 +3,13 @@
import com.xcong.excoin.common.exception.GlobalException;
import com.xcong.excoin.modules.member.entity.MemberEntity;
import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.HttpRequest;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
/**
* 登陆用户工具类
@@ -28,6 +34,11 @@
return (String) SecurityContextHolder.getContext().getAuthentication().getCredentials();
}
+ public static void resetAppLoginUser(MemberEntity memberEntity) {
+ Authentication authentication = new UsernamePasswordAuthenticationToken(memberEntity, getAppLoginUserToken(), new ArrayList<>());
+ SecurityContextHolder.getContext().setAuthentication(authentication);
+ }
+
/**
* mybatis 拦截器专用
*
@@ -44,4 +55,12 @@
return (MemberEntity) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
}
}
+
+ public static boolean isBrowser(HttpServletRequest request) {
+ String userAgent = request.getHeader("user-agent");
+ if (userAgent.toLowerCase().contains("mobile") || userAgent.toLowerCase().contains("okhttp")) {
+ return false;
+ }
+ return true;
+ }
}
--
Gitblit v1.9.1