2024-05-26 14:54:02 +03:00
|
|
|
/**
|
|
|
|
* Module: Models for Users.
|
|
|
|
*/
|
|
|
|
|
2024-06-02 23:41:46 +03:00
|
|
|
import { LibraryItemID } from './library';
|
|
|
|
|
2024-05-27 20:42:34 +03:00
|
|
|
/**
|
|
|
|
* Represents {@link User} identifier type.
|
|
|
|
*/
|
|
|
|
export type UserID = number;
|
|
|
|
|
2024-05-26 14:54:02 +03:00
|
|
|
/**
|
|
|
|
* Represents user detailed information.
|
|
|
|
* Some information should only be accessible to authorized users
|
|
|
|
*/
|
|
|
|
export interface IUser {
|
2024-05-27 20:42:34 +03:00
|
|
|
id: UserID;
|
2024-05-26 14:54:02 +03:00
|
|
|
username: string;
|
|
|
|
is_staff: boolean;
|
|
|
|
email: string;
|
|
|
|
first_name: string;
|
|
|
|
last_name: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents CurrentUser information.
|
|
|
|
*/
|
2025-01-28 19:47:24 +03:00
|
|
|
export interface ICurrentUser {
|
|
|
|
id: UserID | null;
|
|
|
|
username: string;
|
|
|
|
is_staff: boolean;
|
2024-06-03 01:17:27 +03:00
|
|
|
editor: LibraryItemID[];
|
2024-05-26 14:54:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents signup data, used to create new users.
|
|
|
|
*/
|
|
|
|
export interface IUserSignupData extends Omit<IUser, 'is_staff' | 'id'> {
|
|
|
|
password: string;
|
|
|
|
password2: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents user profile for viewing and editing {@link IUser}.
|
|
|
|
*/
|
|
|
|
export interface IUserProfile extends Omit<IUser, 'is_staff'> {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents user reference information.
|
|
|
|
*/
|
|
|
|
export interface IUserInfo extends Omit<IUserProfile, 'email' | 'username'> {}
|
|
|
|
|
2024-05-27 20:42:34 +03:00
|
|
|
/**
|
|
|
|
* Represents user access mode.
|
|
|
|
*/
|
2025-01-15 23:03:35 +03:00
|
|
|
export enum UserRole {
|
2024-05-27 20:42:34 +03:00
|
|
|
READER = 0,
|
|
|
|
EDITOR,
|
|
|
|
OWNER,
|
|
|
|
ADMIN
|
2024-05-26 14:54:02 +03:00
|
|
|
}
|