Commit 15aecf4f by 吴学德

无手机验证码登录

parent 2f2149ed
package com.winsun.item.modular.config; package com.winsun.item.modular.config;
import com.winsun.item.modular.intercept.ChangePwdInterceptor;
import com.winsun.item.modular.intercept.LoginInterceptor; import com.winsun.item.modular.intercept.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
...@@ -20,11 +21,15 @@ public class LoginApplicaionConfig extends WebMvcConfigurationSupport { ...@@ -20,11 +21,15 @@ public class LoginApplicaionConfig extends WebMvcConfigurationSupport {
@Autowired @Autowired
private LoginInterceptor loginInterceptor; private LoginInterceptor loginInterceptor;
@Autowired
private ChangePwdInterceptor changePwdInterceptor;
@Override @Override
public void addInterceptors(InterceptorRegistry registry) { public void addInterceptors(InterceptorRegistry registry) {
// login 路径进行拦截 // login changePwd路径进行拦截
registry.addInterceptor(loginInterceptor).addPathPatterns("/login"); registry.addInterceptor(loginInterceptor).addPathPatterns("/login");
registry.addInterceptor(changePwdInterceptor).addPathPatterns("/mgr/changePwd");
super.addInterceptors(registry); super.addInterceptors(registry);
} }
......
package com.winsun.item.modular.intercept;
import com.winsun.item.core.shiro.ShiroKit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @Author xuede
* @Date 2020/2/29 18:01
* @Version 1.0
*/
@Component
public class ChangePwdInterceptor extends HandlerInterceptorAdapter {
@Autowired
public StringRedisTemplate stringRedisTemplate;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception {
Integer userid = ShiroKit.getUser().getId();
if (userid==null){
return false;
}
stringRedisTemplate.opsForValue().set(userid.toString(),"XXXXXX");
return true;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment