zwzw1219 2017-10-14 10:06:50 +08:00
parent 35cf0df44e
commit 8fc4348b93
2 changed files with 11 additions and 9 deletions

View File

@ -27,11 +27,12 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests() http.authorizeRequests()
.antMatchers("/statics/**", "/v2/api-docs/**", "/swagger-resources/**", "/swagger-ui.html", .antMatchers("/login.html", "/statics/**", "/v2/api-docs/**", "/swagger-resources/**",
"/webjars/**") "/swagger-ui.html", "/webjars/**")
.permitAll().anyRequest().authenticated().and().formLogin().loginProcessingUrl("/login") .permitAll().anyRequest().authenticated().and().formLogin().loginPage("/login.html")
.successHandler(authenticationSuccessHandler).failureHandler(authenticationFailureHandler).and() .loginProcessingUrl("/login").successHandler(authenticationSuccessHandler)
.logout().logoutUrl("/logout").logoutSuccessHandler(logoutSuccessHandler).and().csrf().disable(); .failureHandler(authenticationFailureHandler).and().logout().logoutUrl("/logout")
.logoutSuccessHandler(logoutSuccessHandler).and().csrf().disable();
} }
@Override @Override

View File

@ -38,10 +38,10 @@
parent.location.href = '/login.html'; parent.location.href = '/login.html';
} }
var user = loginInfo(); /* var user = loginInfo();
if (user != "") { if (user != "") {
location.href = '/'; location.href = '/';
} } */
function login(obj) { function login(obj) {
$(obj).attr("disabled", true); $(obj).attr("disabled", true);
@ -54,9 +54,10 @@
} else { } else {
$.ajax({ $.ajax({
type : 'post', type : 'post',
url : '/sys/login', url : '/login',
data : $("#login-form").serialize(), data : $("#login-form").serialize(),
success : function() { success : function(data) {
console.log(data)
location.href = '/'; location.href = '/';
}, },
error : function(xhr, textStatus, errorThrown) { error : function(xhr, textStatus, errorThrown) {