source: trip-planner/src/main/java/finki/diplomska/tripplanner/models/User.java@ 1ad8e64

Last change on this file since 1ad8e64 was 1ad8e64, checked in by Ema <ema_spirova@…>, 3 years ago

spring security

  • Property mode set to 100644
File size: 1.8 KB
Line 
1package finki.diplomska.tripplanner.models;
2
3import com.fasterxml.jackson.annotation.JsonIgnore;
4import lombok.AllArgsConstructor;
5import lombok.Getter;
6import lombok.Setter;
7import org.springframework.security.core.GrantedAuthority;
8import org.springframework.security.core.userdetails.UserDetails;
9
10import javax.persistence.*;
11import javax.validation.constraints.Email;
12import javax.validation.constraints.NotBlank;
13import java.util.Collection;
14import java.util.Date;
15
16@Entity
17@Table(name = "users")
18@AllArgsConstructor
19@Getter
20@Setter
21public class User implements UserDetails {
22
23 @Id
24 @GeneratedValue(strategy = GenerationType.IDENTITY)
25 private Long id;
26
27 @Email(message = "Username needs to be an email")
28 @NotBlank(message = "username is required")
29 @Column(unique = true)
30 private String username;
31 @NotBlank(message = "Please enter your full name")
32 private String fullName;
33 @NotBlank(message = "Password field is required")
34 private String password;
35 @Transient
36 private String confirmPassword;
37 private Date create_At;
38 private Date update_At;
39
40 //OneToMany with Project
41
42 public User() {
43 }
44
45
46 @PrePersist
47 protected void onCreate(){
48 this.create_At = new Date();
49 }
50 @PreUpdate
51 protected void onUpdate(){
52 this.update_At = new Date();
53 }
54
55 @Override
56 @JsonIgnore
57 public Collection<? extends GrantedAuthority> getAuthorities() {
58 return null;
59 }
60
61 @Override
62 @JsonIgnore
63 public boolean isAccountNonExpired() {
64 return true;
65 }
66
67 @Override
68 @JsonIgnore
69 public boolean isAccountNonLocked() {
70 return true;
71 }
72
73 @Override
74 @JsonIgnore
75 public boolean isCredentialsNonExpired() {
76 return true;
77 }
78
79 @Override
80 @JsonIgnore
81 public boolean isEnabled() {
82 return true;
83 }
84}
Note: See TracBrowser for help on using the repository browser.