java - Not able to authenticate user by email_id in spring security -


i want use email_id of user username reason when try authenticate email_id not working, redirected error page.

here implementation of security config

    @autowired     public void configureglobal(authenticationmanagerbuilder auth) throws exception {         auth.jdbcauthentication().datasource(datasource).passwordencoder(passwordencoder())         .usersbyusernamequery(             "select email_id,password,enabled users email_id = ?")             .authoritiesbyusernamequery(             "select email_id,'user_role' users email_id = ?");     } 

ps: tried surrounding ? '?' thinking email_id not passed correctly.

login page jsp

<form method="post" th:action="@{/login}" name="f">              <fieldset>                 <%-- <div th:if="${param.error}" class="alert alert-error">                          invalid username , password.                  </div>                  <div th:if="${param.logout}" class="alert alert-success">                       have been logged out.                   </div> --%>                  <input type="hidden" name="${_csrf.parametername}" value="${_csrf.token}"/>                  <div class="margin-top-10  form-group">                     <input class="form-control input-lg" type="text" id="username" name="username" placeholder="username" />                  </div>                  <div class="margin-top-10 form-group">                     <input class="form-control input-lg" type="password" id="password" name="password" placeholder="password"/>                  </div>                     <div class="margin-top-10 form-actions form-group">                     <button type="submit" class="btn btn-default btn-primary">login</button>                     <a class="register-link">register</a>                  </div>                  </fieldset>             </form> 

you'll need set in httpsecurity form login configuration spring security accepts custom username , password fields:

@override public void configure(httpsecurity http) throws exception {     http         .authorizerequests()         .anyrequest().authenticated()         .and()         .formlogin().usernameparameter("email_id").passwordparameter("password").permitall(); } 

Comments