Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
sentinel
Project
Project
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
曲欣亮
sentinel
Commits
2f745854
Commit
2f745854
authored
Sep 29, 2018
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加会员登陆拦截
parent
c84f2968
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
0 deletions
+32
-0
WebMvcConfig.java
src/main/java/com/egolm/film/config/WebMvcConfig.java
+4
-0
MemberLoginInterceptor.java
...egolm/film/config/interceptor/MemberLoginInterceptor.java
+28
-0
No files found.
src/main/java/com/egolm/film/config/WebMvcConfig.java
View file @
2f745854
...
...
@@ -29,11 +29,15 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter {
@Autowired
private
UserLoginInterceptor
userLoginInterceptor
;
@Autowired
private
UserLoginInterceptor
memberLoginInterceptor
;
@Override
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
registry
.
addInterceptor
(
adminLoginInterceptor
).
addPathPatterns
(
"/admin/**"
).
excludePathPatterns
(
"/admin/login"
);
registry
.
addInterceptor
(
userLoginInterceptor
).
addPathPatterns
(
"/user/**"
).
excludePathPatterns
(
"/user/login"
);
registry
.
addInterceptor
(
memberLoginInterceptor
).
addPathPatterns
(
"/member/**"
).
excludePathPatterns
(
"/member/login"
);
}
@Override
...
...
src/main/java/com/egolm/film/config/interceptor/MemberLoginInterceptor.java
0 → 100644
View file @
2f745854
package
com
.
egolm
.
film
.
config
.
interceptor
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.servlet.handler.HandlerInterceptorAdapter
;
import
com.egolm.film.config.XException
;
import
com.egolm.film.login.service.MemberTokenService
;
@Component
public
class
MemberLoginInterceptor
extends
HandlerInterceptorAdapter
{
@Autowired
private
MemberTokenService
tokenService
;
@Override
public
boolean
preHandle
(
HttpServletRequest
req
,
HttpServletResponse
resp
,
Object
handler
)
throws
Exception
{
if
(
tokenService
.
isLogin
())
{
return
super
.
preHandle
(
req
,
resp
,
handler
);
}
else
{
throw
new
XException
(
"用户未登陆"
);
}
}
}
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