content: package com.example.identityservice.user;
  
  import com.example.identityservice.token.Token;
  import jakarta.persistence.*;
  import lombok.AllArgsConstructor;
  import lombok.Builder;
  import lombok.Data;
  import lombok.NoArgsConstructor;
  import org.springframework.security.core.GrantedAuthority;
  import org.springframework.security.core.authority.SimpleGrantedAuthority;
  import org.springframework.security.core.userdetails.UserDetails;
  
  import java.util.Collection;
  import java.util.List;
  
  @Entity
  @Table(name = "USERS")
  @Data
  @Builder
  @NoArgsConstructor
  @AllArgsConstructor
  public class User implements UserDetails {
  
      @Id
      @Column(name = "ID")
      @GeneratedValue(strategy=GenerationType.IDENTITY)
      private Integer id;
  
      @Column(name = "FIRSTNAME")
      private String firstname;
  
      @Column(name = "LASTNAME")
      private String lastname;
  
      @Column(name = "EMAIL")
      private String email;
  
      @Column(name = "PASSWORD")
      private String password;
  
      @Enumerated(EnumType.STRING)
      private Role role;
  
      @OneToMany(mappedBy = "user")
      private List<Token> tokens;
  
      @Override
      public Collection<? extends GrantedAuthority> getAuthorities() {
          return List.of(new SimpleGrantedAuthority(role.name()));
      }
  
      @Override
      public String getPassword() {
          return password;
      }
  
      @Override
      public String getUsername() {
          return email;
      }
  
      @Override
      public boolean isAccountNonExpired() {
          return true;
      }
  
      @Override
      public boolean isAccountNonLocked() {
          return true;
      }
  
      @Override
      public boolean isCredentialsNonExpired() {
          return true;
      }
  
      @Override
      public boolean isEnabled() {
          return true;
      }
  }
  