Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gdtel-gztel-school-center
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
吴学德
gdtel-gztel-school-center
Commits
2f2149ed
Commit
2f2149ed
authored
Feb 29, 2020
by
吴学德
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
无手机验证码登录
parent
de1c0037
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
0 deletions
+84
-0
core-service/src/main/java/com/winsun/item/modular/config/LoginApplicaionConfig.java
+31
-0
core-service/src/main/java/com/winsun/item/modular/intercept/LoginInterceptor.java
+53
-0
No files found.
core-service/src/main/java/com/winsun/item/modular/config/LoginApplicaionConfig.java
0 → 100644
View file @
2f2149ed
package
com
.
winsun
.
item
.
modular
.
config
;
import
com.winsun.item.modular.intercept.LoginInterceptor
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.web.servlet.config.annotation.InterceptorRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
/**
* @Author xuede
* @Date 2020/2/29 16:11
* @Version 1.0
*/
@Configuration
public
class
LoginApplicaionConfig
extends
WebMvcConfigurationSupport
{
@Autowired
private
LoginInterceptor
loginInterceptor
;
@Override
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
// login 路径进行拦截
registry
.
addInterceptor
(
loginInterceptor
).
addPathPatterns
(
"/login"
);
super
.
addInterceptors
(
registry
);
}
}
core-service/src/main/java/com/winsun/item/modular/intercept/LoginInterceptor.java
0 → 100644
View file @
2f2149ed
package
com
.
winsun
.
item
.
modular
.
intercept
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.servlet.ModelAndView
;
import
org.springframework.web.servlet.handler.HandlerInterceptorAdapter
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
/**
* @Author xuede
* @Date 2020/2/29 16:07
* @Version 1.0
*/
@Component
public
class
LoginInterceptor
extends
HandlerInterceptorAdapter
{
//登录验证码标识
private
static
String
CODE
=
"getPhoneCode"
;
@Autowired
public
StringRedisTemplate
stringRedisTemplate
;
@Override
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
o
)
throws
Exception
{
Object
username
=
request
.
getParameter
(
"username"
);
if
(
username
==
null
){
return
false
;
}
stringRedisTemplate
.
opsForValue
().
set
(
username
+
CODE
,
"XXXXXX"
);
return
true
;
}
@Override
public
void
postHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
,
ModelAndView
modelAndView
)
throws
Exception
{
super
.
postHandle
(
request
,
response
,
handler
,
modelAndView
);
}
@Override
public
void
afterCompletion
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
,
Exception
ex
)
throws
Exception
{
super
.
afterCompletion
(
request
,
response
,
handler
,
ex
);
}
@Override
public
void
afterConcurrentHandlingStarted
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
throws
Exception
{
super
.
afterConcurrentHandlingStarted
(
request
,
response
,
handler
);
}
}
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