修改表名称
This commit is contained in:
parent
19a83fddc1
commit
8de5bdb55d
|
|
@ -53,10 +53,9 @@ public class BnsSecurityConfig extends WebSecurityConfigurerAdapter {
|
|||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
http.authorizeRequests()//开启登录配置
|
||||
.antMatchers("/gzRealName/**","/user/**","/offLine/**").permitAll()
|
||||
.anyRequest().authenticated()//表示剩余的其他接口,登录之后就能访问
|
||||
.and()
|
||||
.formLogin()
|
||||
.antMatchers("/gzRealName/**","/user/**","/offLine/**","/login").permitAll()
|
||||
.anyRequest().authenticated();//表示剩余的其他接口,登录之后就能访问
|
||||
http.formLogin().loginProcessingUrl("/login")
|
||||
//登录成功的处理器
|
||||
.successHandler(new AuthenticationSuccessHandler() {
|
||||
@Override
|
||||
|
|
@ -109,7 +108,6 @@ public class BnsSecurityConfig extends WebSecurityConfigurerAdapter {
|
|||
ResponseUtil.responseJson(resp, HttpStatus.OK.value(), map);
|
||||
}
|
||||
})
|
||||
.permitAll()//和表单登录相关的接口统统都直接通过
|
||||
.and()
|
||||
.logout()
|
||||
.logoutUrl("/logout")
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@ package com.bonus.hnrn.rnama.core.config;
|
|||
|
||||
import com.bonus.hnrn.rnama.core.entity.UserBean;
|
||||
import com.bonus.hnrn.rnama.core.service.TokenService;
|
||||
import com.bonus.hnrn.rnama.core.util.ResponseUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
|
|
@ -15,6 +17,7 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Token过滤器
|
||||
|
|
@ -34,6 +37,18 @@ public class TokenFilter extends OncePerRequestFilter {
|
|||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
|
||||
throws ServletException, IOException {
|
||||
String token = getToken(request);
|
||||
String requestURI = request.getRequestURI();
|
||||
if ("/login".equals(requestURI)) {
|
||||
filterChain.doFilter(request, response);
|
||||
return;
|
||||
}else{
|
||||
if (StringUtils.isEmpty(token)) {
|
||||
// 无 Token 时返回 401
|
||||
ResponseUtil.responseJson(response, HttpStatus.UNAUTHORIZED.value(),
|
||||
Collections.singletonMap("msg", "未登录或 Token 过期"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotBlank(token)) {
|
||||
UserBean loginUser = tokenService.getLoginUser(token);
|
||||
if (loginUser != null) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue