source: src/main/java/com/example/moviezone/model/User.java@ ac25203

Last change on this file since ac25203 was ac25203, checked in by DenicaKj <dkorvezir@…>, 22 months ago

Spring Security

  • Property mode set to 100644
File size: 2.0 KB
Line 
1package com.example.moviezone.model;
2
3import jakarta.persistence.*;
4import lombok.Getter;
5import lombok.Setter;
6import lombok.ToString;
7import org.springframework.security.core.GrantedAuthority;
8import org.springframework.security.core.userdetails.UserDetails;
9
10import javax.management.relation.Role;
11import java.time.LocalDateTime;
12import java.util.Collection;
13
14@Entity
15@Getter
16@Setter
17@ToString
18@Table(name = "users")
19@Inheritance(strategy = InheritanceType.JOINED)
20public class User implements UserDetails {
21
22 @Id
23 @GeneratedValue(strategy = GenerationType.IDENTITY)
24 Integer id_user;
25 String password;
26 String first_name;
27 String last_name;
28 String address;
29 String contact_number;
30 String username;
31 LocalDateTime date_created;
32
33 private boolean isAccountNonExpired = true;
34 private boolean isAccountNonLocked = true;
35 private boolean isCredentialsNonExpired = true;
36 private boolean isEnabled = true;
37
38 @Enumerated(value = EnumType.STRING)
39 private Role role;
40
41 public User(Integer id_user, String password, String first_name, String last_name, String address, String contact_number, String username, LocalDateTime date_created, Role role) {
42 this.id_user = id_user;
43 this.password = password;
44 this.first_name = first_name;
45 this.last_name = last_name;
46 this.address = address;
47 this.contact_number = contact_number;
48 this.username = username;
49 this.date_created = date_created;
50 this.role = role;
51 }
52
53 public User() {
54
55 }
56
57 @Override
58 public Collection<? extends GrantedAuthority> getAuthorities() {
59 return null;
60 }
61
62
63 @Override
64 public boolean isAccountNonExpired() {
65 return isAccountNonExpired;
66 }
67
68 @Override
69 public boolean isAccountNonLocked() {
70 return isAccountNonLocked;
71 }
72
73 @Override
74 public boolean isCredentialsNonExpired() {
75 return isCredentialsNonExpired;
76 }
77
78 @Override
79 public boolean isEnabled() {
80 return isEnabled;
81 }
82
83}
Note: See TracBrowser for help on using the repository browser.