Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cloud-fb
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王衍超
cloud-fb
Commits
add51102
Commit
add51102
authored
Mar 24, 2021
by
PWF-WK01\pengwufeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
登录缓存区域公司信息
parent
2ada3539
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
0 deletions
+36
-0
AuthcConstants.java
.../beecode/inz/authentication/constants/AuthcConstants.java
+5
-0
RESTAppAuthenticationSuccessHandler.java
...tication/handler/RESTAppAuthenticationSuccessHandler.java
+31
-0
No files found.
backend/inz.authentication/src/main/java/com/beecode/inz/authentication/constants/AuthcConstants.java
View file @
add51102
...
...
@@ -15,6 +15,11 @@ public interface AuthcConstants {
public
String
CURRENTUSER
=
"currentUser"
;
/**
* 当前用户数据集
*/
public
String
CURRENTUSERDATAS
=
"currentUserDatas"
;
/**
* 当前用户名称
*/
public
String
USERNAME
=
"username"
;
...
...
backend/inz.authentication/src/main/java/com/beecode/inz/authentication/handler/RESTAppAuthenticationSuccessHandler.java
View file @
add51102
...
...
@@ -2,10 +2,13 @@ package com.beecode.inz.authentication.handler;
import
java.io.IOException
;
import
java.util.Date
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
javax.servlet.ServletException
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpSession
;
import
org.json.JSONObject
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -31,6 +34,11 @@ import com.beecode.inz.authentication.util.LoginLogUtil;
@Component
public
class
RESTAppAuthenticationSuccessHandler
extends
SimpleUrlAuthenticationSuccessHandler
{
/**
* 登录时区域公司的参数key
*/
private
final
static
String
REQUEST_CURRENTREGIONALCOMPANY_KEY
=
"currentRegionalCompany"
;
@Autowired
private
TenantUserService
tenantUserService
;
@Autowired
...
...
@@ -52,8 +60,13 @@ public class RESTAppAuthenticationSuccessHandler extends SimpleUrlAuthentication
request
.
getSession
().
setAttribute
(
AuthcConstants
.
USERID
,
tenantUser
.
getUserId
());
request
.
getSession
().
setAttribute
(
"mobile"
,
true
);
request
.
getSession
().
setMaxInactiveInterval
(
30
*
24
*
60
*
60
);
//构建当前用户数据集
buildCurrentUserDatas
(
request
);
loginLog
.
setTenantId
(
tenantUser
.
getTenantId
());
loginLogService
.
insert
(
loginLog
);
ServletRequestAttributes
attr
=
(
ServletRequestAttributes
)
RequestContextHolder
.
currentRequestAttributes
();
returnJson
.
put
(
AuthcConstants
.
USERID
,
tenantUser
.
getUserId
());
returnJson
.
put
(
AuthcConstants
.
USERNAME
,
tenantUser
.
getUsername
());
...
...
@@ -68,9 +81,27 @@ public class RESTAppAuthenticationSuccessHandler extends SimpleUrlAuthentication
}
finally
{
}
}
/**
* 构造当前用户数据集
*/
private
void
buildCurrentUserDatas
(
HttpServletRequest
request
)
{
HttpSession
session
=
request
.
getSession
();
//获取当前用户区域公司参数,存入当前用户数据集(session)
String
currentRegionalCompany
=
obtainCurrentRegionalCompany
(
request
);
Map
<
String
,
String
>
datas
=
new
ConcurrentHashMap
<>();
datas
.
put
(
REQUEST_CURRENTREGIONALCOMPANY_KEY
,
currentRegionalCompany
);
//目前数据集只存了用户区域公司
session
.
setAttribute
(
AuthcConstants
.
CURRENTUSERDATAS
,
datas
);
}
private
String
obtainCurrentRegionalCompany
(
HttpServletRequest
request
)
{
return
request
.
getParameter
(
REQUEST_CURRENTREGIONALCOMPANY_KEY
);
}
public
LoginLog
getLoginLog
(
HttpServletRequest
request
){
LoginLog
loginLog
=
new
LoginLog
();
String
userAgent
=
request
.
getHeader
(
LoginLogConstants
.
USER_AGENT
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment