Commit 5f0823e9 authored by WeiWei's avatar WeiWei

测试domain

parent 36c38834
......@@ -14,7 +14,6 @@ import javax.validation.Valid;
/**
* Created by WeiWei on 2019/7/22.
*/
@CrossOrigin
@RestController
public class LogController {
......@@ -27,6 +26,7 @@ public class LogController {
* @param loginFormModel
* @return
*/
@CrossOrigin(allowCredentials = "true")
@PostMapping("/login")
public Result<Boolean> login(@RequestBody @Valid LoginFormModel loginFormModel) {
return new Result<>(ApplicationStatus.SUCCESS, this.logService.login(loginFormModel.getUsername(), loginFormModel.getPassword()));
......@@ -37,6 +37,7 @@ public class LogController {
*
* @return
*/
@CrossOrigin(allowCredentials = "true")
@DeleteMapping("/logout")
@Security(authorityId = "Log.logout", authorities = Authority.READ)
public Result<Boolean> logout() {
......
......@@ -66,12 +66,13 @@ public class LogService {
session.setAttribute(ApplicationDictionary.PRINCIPAL, JSONTools.serialize(principal));
Cookie cookie = new Cookie("JSESSIONID", session.getId());
log.info("登录客户端IP:{}", request.getRemoteAddr());
cookie.setDomain(request.getRemoteAddr());
cookie.setPath("/");
this.response.addCookie(cookie);
// Cookie cookie = new Cookie("JSESSIONID", session.getId());
// log.info("登录客户端IP:{}", request.getRemoteAddr());
// cookie.setHttpOnly(false);
// cookie.setDomain(request.getRemoteAddr());
// cookie.setPath("/");
//
// this.response.addCookie(cookie);
return true;
......
......@@ -11,14 +11,16 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
* @author: suntao
*/
@Configuration
public class CorsConfiguration extends WebMvcConfigurerAdapter{
public class CorsConfiguration extends WebMvcConfigurerAdapter {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedMethods("*")
.allowedOrigins("*")
.allowedHeaders("*");
super.addCorsMappings(registry);
.allowedMethods("GET", "HEAD", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "TRACE")
.allowCredentials(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