@@ -8,26 +8,29 @@ import { UserAction } from './UserAction';
|
||||
import { UserGroup } from './UserGroup';
|
||||
|
||||
/**
|
||||
* Defines a admin user.
|
||||
* Defines the User entity.
|
||||
* Users are the ones that can use the "admin" webui and do stuff in the backend.
|
||||
*/
|
||||
@ChildEntity()
|
||||
export class User extends Principal {
|
||||
/**
|
||||
* uuid
|
||||
* The user's uuid.
|
||||
* Mainly gets used as a per-user salt for the password hash.
|
||||
*/
|
||||
@Column({ unique: true })
|
||||
@IsUUID(4)
|
||||
uuid: string;
|
||||
|
||||
/**
|
||||
* user email
|
||||
* The user's e-mail address.
|
||||
* Either username or email has to be set (otherwise the user couldn't log in).
|
||||
*/
|
||||
@Column({ nullable: true, unique: true })
|
||||
@IsEmail()
|
||||
email?: string;
|
||||
|
||||
/**
|
||||
* user phone
|
||||
* The user's phone number.
|
||||
*/
|
||||
@Column({ nullable: true })
|
||||
@IsOptional()
|
||||
@@ -35,14 +38,15 @@ export class User extends Principal {
|
||||
phone?: string;
|
||||
|
||||
/**
|
||||
* username
|
||||
* The user's username.
|
||||
* Either username or email has to be set (otherwise the user couldn't log in).
|
||||
*/
|
||||
@Column({ nullable: true, unique: true })
|
||||
@IsString()
|
||||
username?: string;
|
||||
|
||||
/**
|
||||
* firstname
|
||||
* The user's first name.
|
||||
*/
|
||||
@Column()
|
||||
@IsString()
|
||||
@@ -50,7 +54,7 @@ export class User extends Principal {
|
||||
firstname: string;
|
||||
|
||||
/**
|
||||
* middlename
|
||||
* The user's middle name.
|
||||
*/
|
||||
@Column({ nullable: true })
|
||||
@IsString()
|
||||
@@ -58,7 +62,7 @@ export class User extends Principal {
|
||||
middlename?: string;
|
||||
|
||||
/**
|
||||
* lastname
|
||||
* The user's last name.
|
||||
*/
|
||||
@Column()
|
||||
@IsString()
|
||||
@@ -66,7 +70,8 @@ export class User extends Principal {
|
||||
lastname: string;
|
||||
|
||||
/**
|
||||
* password
|
||||
* The user's password.
|
||||
* This is a argon2 hash salted with the user's uuid.
|
||||
*/
|
||||
@Column()
|
||||
@IsString()
|
||||
@@ -74,7 +79,8 @@ export class User extends Principal {
|
||||
password: string;
|
||||
|
||||
/**
|
||||
* groups
|
||||
* The groups this user is a part of.
|
||||
* The user will inherit the groups permissions (without overwriting his own).
|
||||
*/
|
||||
@IsOptional()
|
||||
@ManyToMany(() => UserGroup, { nullable: true })
|
||||
@@ -82,21 +88,23 @@ export class User extends Principal {
|
||||
groups: UserGroup[];
|
||||
|
||||
/**
|
||||
* is user enabled?
|
||||
* Is this user enabled?
|
||||
*/
|
||||
@Column()
|
||||
@IsBoolean()
|
||||
enabled: boolean = true;
|
||||
|
||||
/**
|
||||
* jwt refresh count
|
||||
* The user's jwt refresh token count.
|
||||
* Used to invalidate jwts.
|
||||
*/
|
||||
@IsInt()
|
||||
@Column({ default: 1 })
|
||||
refreshTokenCount?: number;
|
||||
|
||||
/**
|
||||
* profilepic
|
||||
* The user's profile picture.
|
||||
* We haven't decided yet if this will be a bas64 encoded image or just a link to the profile picture.
|
||||
*/
|
||||
@Column({ nullable: true, unique: true })
|
||||
@IsString()
|
||||
@@ -104,14 +112,15 @@ export class User extends Principal {
|
||||
profilePic?: string;
|
||||
|
||||
/**
|
||||
* actions
|
||||
* The actions performed by this user.
|
||||
* For documentation purposes only, will be implemented later.
|
||||
*/
|
||||
@IsOptional()
|
||||
@OneToMany(() => UserAction, action => action.user, { nullable: true })
|
||||
actions: UserAction[]
|
||||
|
||||
/**
|
||||
* Turn this into a response.
|
||||
* Turns this entity into it's response class.
|
||||
*/
|
||||
public toResponse(): ResponsePrincipal {
|
||||
return new ResponseUser(this);
|
||||
|
||||
Reference in New Issue
Block a user