38 lines
801 B
Java
38 lines
801 B
Java
|
package org.hso.ecommerce.entities;
|
||
|
|
||
|
import javax.persistence.*;
|
||
|
import org.springframework.security.crypto.bcrypt.BCrypt;
|
||
|
|
||
|
|
||
|
@Entity
|
||
|
@Table(name = "users")
|
||
|
public class User {
|
||
|
|
||
|
@Id
|
||
|
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||
|
@Basic
|
||
|
public long id;
|
||
|
public java.sql.Timestamp created;
|
||
|
|
||
|
@Column(unique = true)
|
||
|
public String email;
|
||
|
public String passwordHash;
|
||
|
|
||
|
public boolean isActive;
|
||
|
public boolean isEmployee;
|
||
|
public boolean getsAds;
|
||
|
public boolean isB2B;
|
||
|
|
||
|
public long getId() {
|
||
|
return id;
|
||
|
}
|
||
|
|
||
|
public boolean validatePassword(String password) {
|
||
|
return BCrypt.checkpw(password, passwordHash);
|
||
|
}
|
||
|
|
||
|
public void setPassword(String password) {
|
||
|
passwordHash = BCrypt.hashpw(password, BCrypt.gensalt());
|
||
|
}
|
||
|
}
|