新增注销接口
This commit is contained in:
parent
1aa4607fe3
commit
efe4570a5b
@ -27,7 +27,6 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.authorizeRequests()
|
||||
.anyRequest().permitAll()
|
||||
.and().formLogin().loginPage("/").permitAll()
|
||||
.and().logout().logoutSuccessUrl("/").permitAll()
|
||||
.and()
|
||||
.addFilterAt(authenticationProcessingFilter, UsernamePasswordAuthenticationFilter.class)
|
||||
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
|
||||
|
@ -1,10 +1,16 @@
|
||||
package icu.mmmc.InventoryProMax.controller;
|
||||
|
||||
import icu.mmmc.InventoryProMax.vo.ResultStatus;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.annotation.security.PermitAll;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* 主页
|
||||
@ -19,4 +25,12 @@ public class IndexController {
|
||||
public ModelAndView userLogin() {
|
||||
return new ModelAndView("/login.html");
|
||||
}
|
||||
|
||||
@PermitAll
|
||||
@ResponseBody
|
||||
@PostMapping(value = "/logout")
|
||||
public ResultStatus logout(HttpServletResponse response) {
|
||||
response.addCookie(new Cookie(HttpHeaders.AUTHORIZATION, null));
|
||||
return new ResultStatus(true, "/");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user