title: SpringBoot: Imp SpringSecurity : while login with user/pass getting Screen error msg "User is disabled"
body: <p>I just start implementing SpringSecurity but post login getting Error Message on Screen "User is disabled"</p>
  
  <p>IT'S WORKING VERY WELL FOR DEFAULT .
  WHILE HITTING WITH /user or /admin and trying to login it's showing <strong>"User is disable"</strong>   </p>
  
  <p>I am following below step:</p>
  
  <ol>
  <li><p>First created schema.sql (under resource folder)</p>
  
  <pre class="lang-sql prettyprint-override"><code>CREATE TABLE USERS (
      USERNAME VARCHAR(128) PRIMARY KEY,
      PASSWORD VARCHAR(128) NOT NULL,
      ENABLED CHAR(1) CHECK (ENABLED IN ('Y','N') ) NOT NULL
  );
  
  CREATE TABLE AUTHORITIES (
      USERNAME VARCHAR(128) NOT NULL,
      AUTHORITY VARCHAR(128) NOT NULL
  );
  
  ALTER TABLE AUTHORITIES ADD CONSTRAINT AUTHORITIES_UNIQUE UNIQUE (USERNAME, AUTHORITY);
  ALTER TABLE AUTHORITIES ADD CONSTRAINT AUTHORITIES_FK1 FOREIGN KEY (USERNAME) REFERENCES USERS (USERNAME);
  </code></pre></li>
  <li><p>Created "data.sql" under resource folder</p>
  
  <pre class="lang-sql prettyprint-override"><code>insert into USERS(USERNAME,PASSWORD,ENABLED) VALUES ('user','pass','Y');
  insert into USERS(USERNAME,PASSWORD,ENABLED) VALUES ('admin','pass','Y');
  insert into AUTHORITIES (USERNAME,AUTHORITY) values ('user','ROLE_USER');
  insert into AUTHORITIES (USERNAME,AUTHORITY) values ('admin','ROLE_ADMIN');
  </code></pre></li>
  <li><p>HomeResource.JAVA ( This is a controller class API)</p>
  
  <pre class="lang-java prettyprint-override"><code>package com.example.callCenter;
  
  import org.springframework.web.bind.annotation.GetMapping;
  import org.springframework.web.bind.annotation.RestController;
  
  @RestController
  public class HomeResource{
  
      @GetMapping("/")
      public String home(){
          return("&lt;h1&gt;Welcome home page..&lt;/h1&gt;");
      }
  
      @GetMapping("/user")
      public String user()
      {
          return ("&lt;h1&gt;Welcome User page&lt;/h1&gt;");
      }
  
      @GetMapping("/admin")
      public String admin()
      {
          return("&lt;h1&gt;Welcome Admin page&lt;/h1&gt;");
      }
  }
  </code></pre></li>
  <li><p>SecurityConfiguration.java ( This is enable the Spring Form PAGE)</p>
  
  <pre class="lang-java prettyprint-override"><code>package com.example.callCenter;
  
  import javax.sql.DataSource;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.context.annotation.Bean;
  import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
  import org.springframework.security.config.annotation.web.builders.HttpSecurity;
  import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
  import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
  import org.springframework.security.core.userdetails.User;
  import org.springframework.security.crypto.password.NoOpPasswordEncoder;
  import org.springframework.security.crypto.password.PasswordEncoder;
  
  @EnableWebSecurity
  public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
  
      @Autowired
      DataSource dataSource;
  
      @Override
      protected void configure(AuthenticationManagerBuilder auth) throws Exception {
          auth.jdbcAuthentication().dataSource(dataSource)
              .usersByUsernameQuery("select username,password,enabled "
                          + "from users "
                          + "where username = ?")
              .authoritiesByUsernameQuery("select username,AUTHORITY  "
                          + "from AUTHORITIES "
                          + "where username = ?");
  
          // This beloe code is default implementation with MySQL database
          // auth.jdbcAuthentication()
          //         .dataSource(dataSource)
          //         .withDefaultSchema()
          //         .withUser( 
          //                     User.withUsername("user")
          //                     .password("pass")
          //                     .roles("USER")
  
          //         )
          //         .withUser( 
          //                     User.withUsername("admin")
          //                     .password("pass")
          //                     .roles("ADMIN")
          //         );
  
      }
  
      @Override
      protected void configure(HttpSecurity http) throws Exception {
          http.csrf().disable()
              .authorizeRequests()
                  .antMatchers("/admin").hasRole("ADMIN")
                  .antMatchers("/user").hasAnyRole("ADMIN","USER")
                  .antMatchers("/").permitAll()
                  .and().formLogin();
      }
  
      @Bean
      public PasswordEncoder getPasswordEncoder()
      {
          return NoOpPasswordEncoder.getInstance();
      }
  
  }
  </code></pre></li>
  <li><p>CallApplication.java</p>
  
  <pre class="lang-java prettyprint-override"><code>package com.example.callCenter;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  
  @SpringBootApplication
  public class CallApplication {
  
      public static void main(String[] args) {
          SpringApplication.run(CallCenterApplication.class, args);
      }
  
  }
  </code></pre>
  
  <p><strong>pom.xml :</strong> given all the dependency that is not a issue because form is opening</p>
  
  <p><strong>application.properties :</strong></p>
  
  <pre><code>spring.datasource.url=
  spring.datasource.username=
  spring.datasource.password=
  spring.datasource.driverClassName=
  
  spring.jpa.show_sql=true
  spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect
  spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
  spring.jpa.hibernate.ddl-auto=update
  spring.jpa.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect
  spring.jpa.format_sql=true
  </code></pre></li>
  </ol>
  
  <p>I added almost all the details there are nothing pending from my side but now I want some one assistance why it's not allow me to call the user and allow me to login.</p>