diff --git a/spring-jpa/src/main/java/org/baeldung/persistence/model/MyUser.java b/spring-jpa/src/main/java/org/baeldung/persistence/model/MyUser.java index 0a097f2782..804d391641 100644 --- a/spring-jpa/src/main/java/org/baeldung/persistence/model/MyUser.java +++ b/spring-jpa/src/main/java/org/baeldung/persistence/model/MyUser.java @@ -15,16 +15,12 @@ public class MyUser { @GeneratedValue(strategy = GenerationType.AUTO) private int id; - private String name; - @Column(unique = true, nullable = false) private String username; @Column(nullable = false) private String password; - private boolean enabled; - public MyUser() { } @@ -36,14 +32,6 @@ public class MyUser { this.id = id; } - public String getName() { - return name; - } - - public void setName(final String name) { - this.name = name; - } - public String getUsername() { return username; } @@ -59,18 +47,4 @@ public class MyUser { public void setPassword(final String password) { this.password = password; } - - public boolean isEnabled() { - return enabled; - } - - public void setEnabled(final boolean enabled) { - this.enabled = enabled; - } - - @Override - public String toString() { - return "MyUser [name=" + name + ", username=" + username + ", password=" + password + ", enabled=" + enabled + "]"; - } - } diff --git a/spring-jpa/src/main/java/org/baeldung/security/MyUserDetailsService.java b/spring-jpa/src/main/java/org/baeldung/security/MyUserDetailsService.java index 21e3985bac..4c02f53d20 100644 --- a/spring-jpa/src/main/java/org/baeldung/security/MyUserDetailsService.java +++ b/spring-jpa/src/main/java/org/baeldung/security/MyUserDetailsService.java @@ -8,6 +8,7 @@ import org.baeldung.user.dao.MyUserDAO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.core.userdetails.User; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UsernameNotFoundException; @@ -29,7 +30,7 @@ public class MyUserDetailsService implements UserDetailsService { else { final Collection authorities = new ArrayList<>(); authorities.add(new SimpleGrantedAuthority("ROLE_USER")); - return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getPassword(), user.isEnabled(), true, true, true, authorities); + return new User(user.getUsername(), user.getPassword(), authorities); } } diff --git a/spring-jpa/src/main/java/org/baeldung/user/service/MyUserService.java b/spring-jpa/src/main/java/org/baeldung/user/service/MyUserService.java index edbb1651a3..f4705f3193 100644 --- a/spring-jpa/src/main/java/org/baeldung/user/service/MyUserService.java +++ b/spring-jpa/src/main/java/org/baeldung/user/service/MyUserService.java @@ -26,8 +26,6 @@ public class MyUserService { user.setUsername(accountDto.getUsername()); user.setPassword(passwordEncoder.encode(accountDto.getPassword())); - user.setName(accountDto.getName()); - user.setEnabled(true); return myUserDAO.save(user); } diff --git a/spring-jpa/src/main/java/org/baeldung/web/MyUserDto.java b/spring-jpa/src/main/java/org/baeldung/web/MyUserDto.java index ec95ec43bf..c572208913 100644 --- a/spring-jpa/src/main/java/org/baeldung/web/MyUserDto.java +++ b/spring-jpa/src/main/java/org/baeldung/web/MyUserDto.java @@ -8,10 +8,6 @@ public class MyUserDto { @Size(min = 1) private String username; - @NotNull - @Size(min = 1) - private String name; - private String password; public String getUsername() { @@ -21,15 +17,7 @@ public class MyUserDto { public void setUsername(final String username) { this.username = username; } - - public String getName() { - return name; - } - - public void setName(final String name) { - this.name = name; - } - + public String getPassword() { return password; } diff --git a/spring-jpa/src/main/webapp/WEB-INF/views/register.jsp b/spring-jpa/src/main/webapp/WEB-INF/views/register.jsp index 68b3ac14b0..e6e9d373a0 100644 --- a/spring-jpa/src/main/webapp/WEB-INF/views/register.jsp +++ b/spring-jpa/src/main/webapp/WEB-INF/views/register.jsp @@ -16,7 +16,6 @@ Register here:

Username:
Password:
-Name: