java - redirect to the same page after login spring security and spring boot spring 4 -


hi new in spring security

i want not go home page before login used jquery consume login web service every thing going until used spring security can not mange jquery , don't know should can 1 give advice if put "/home" in ant macher every thing works fine need login first see stackoverflow problems topic , of them useless

my controller

@responsebody @requestmapping(value="/index/login",method = requestmethod.post ) public response login(@requestbody logindata logindata){     system.out.println("test ahmed test");     response response = new response(loginrepo.validatelogin(logindata) , "home");     system.out.println("test ahmed test");     return response; } 

my securiy config

public class securityconfig extends websecurityconfigureradapter {  @autowired datasource datasource;  @autowired public void configauthentication(authenticationmanagerbuilder auth) throws exception {     auth.jdbcauthentication().datasource(datasource)             .usersbyusernamequery("select username,password, enabled twitter.login username=?")             .authoritiesbyusernamequery("select username, role twitter.user_roles username=?"); }  @override protected void configure(httpsecurity http) throws exception {     http.csrf().disable();      http.formlogin()             .loginpage("/index")             .usernameparameter("username")             .passwordparameter("password")             .permitall()             .and()             .authorizerequests()             .antmatchers(             "/css/**",             "/css/**",             "/js/**",             "/jquery/**",             "/fonts/**",             "/js/**",             "/img/**",             "/webjars/**",             "/**/favicon.ico",             "/index/**").permitall()             .anyrequest().fullyauthenticated()             .antmatchers("/home").hasauthority("admin")             .and().exceptionhandling().accessdeniedpage("/error/403");  }  } 

my jquery ajax function

                $.ajax({                  contenttype: 'application/json; charset=utf-8',                  type : "post",                   cache : false,                   crossdomain :false,                  url : url+'/login',                 data : json.stringify(formdata),                datatype : 'json',               success : function(result) {              console.log('hiiiiiiiiiii'+result.urlname)             if(result.status == true){                 window.location.href= result.urlname;             }else{                 alert("error! login error please enter vaild username , password")             }             console.log(result);          },          error : function(e) {             alert("error!")             console.log("error: ", e);         }     });          

and response model

private boolean status;  private string urlname;  public response(boolean status , string urlname){     this.status = status;     this.urlname=urlname; }  public boolean isstatus() {     return status; }  public void setstatus(boolean status) {     this.status = status; }  public string geturlname() {     return urlname; }  public void seturlname(string urlname) {     this.urlname = urlname; } } 


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -