2019-11-23 15:10:51 +00:00
|
|
|
import { AccountImage } from "./AccountImage";
|
|
|
|
|
2019-11-23 14:11:33 +00:00
|
|
|
/**
|
|
|
|
* User information
|
|
|
|
*
|
|
|
|
* @author Pierre HUBERT
|
|
|
|
*/
|
|
|
|
|
|
|
|
export enum UserPageStatus {
|
|
|
|
PRIVATE,
|
|
|
|
PUBLIC,
|
|
|
|
OPEN
|
|
|
|
}
|
|
|
|
|
2019-12-29 18:40:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
export interface UserInfo {
|
2019-11-23 14:11:33 +00:00
|
|
|
id: number,
|
|
|
|
firstName: string,
|
|
|
|
lastName: string,
|
|
|
|
timeCreate: number,
|
|
|
|
virtualDirectory: string,
|
|
|
|
pageStatus: UserPageStatus,
|
2019-11-23 15:10:51 +00:00
|
|
|
accountImage: AccountImage,
|
2019-12-28 13:01:10 +00:00
|
|
|
friendsListPublic: boolean,
|
|
|
|
personnalWebsite ?: string,
|
|
|
|
publicNote ?: string,
|
|
|
|
blockComments : boolean,
|
|
|
|
allowPostsFromFriends: boolean,
|
2020-03-21 17:05:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface GeneralSettings {
|
|
|
|
id: number,
|
|
|
|
email ?: string,
|
|
|
|
firstName: string,
|
|
|
|
lastName: string,
|
|
|
|
pageStatus: UserPageStatus,
|
|
|
|
blockComments: boolean,
|
|
|
|
allowPostsFromFriends: boolean,
|
|
|
|
friendsListPublic: boolean,
|
|
|
|
personnalWebsite ?: string,
|
|
|
|
virtualDirectory: string,
|
|
|
|
allowMails: boolean,
|
|
|
|
publicNote ?: string
|
2019-11-23 14:11:33 +00:00
|
|
|
}
|
|
|
|
|
2020-03-21 17:45:45 +00:00
|
|
|
export interface LangSettings {
|
|
|
|
id: number,
|
|
|
|
lang: string,
|
|
|
|
}
|
|
|
|
|
2019-12-29 18:40:35 +00:00
|
|
|
export interface SecuritySettings {
|
|
|
|
id: number,
|
|
|
|
security_question_1 ?: string,
|
|
|
|
security_answer_1 ?: string,
|
|
|
|
security_question_2 ?: string,
|
|
|
|
security_answer_2 ?: string
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-21 17:45:45 +00:00
|
|
|
export interface UserBuilder extends UserInfo, SecuritySettings, LangSettings, GeneralSettings {
|
2019-12-29 18:40:35 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-12-28 13:01:10 +00:00
|
|
|
export class User implements UserBuilder {
|
2019-11-23 14:11:33 +00:00
|
|
|
id: number;
|
2020-03-21 16:16:30 +00:00
|
|
|
email: string;
|
2019-11-23 14:11:33 +00:00
|
|
|
firstName: string;
|
|
|
|
lastName: string;
|
|
|
|
timeCreate: number;
|
|
|
|
virtualDirectory: string;
|
|
|
|
pageStatus: UserPageStatus;
|
2019-11-23 15:10:51 +00:00
|
|
|
accountImage: AccountImage;
|
2019-12-29 18:40:35 +00:00
|
|
|
friendsListPublic: boolean;
|
|
|
|
personnalWebsite?: string;
|
|
|
|
publicNote?: string;
|
|
|
|
blockComments: boolean;
|
|
|
|
allowPostsFromFriends: boolean;
|
2020-03-21 16:16:30 +00:00
|
|
|
allowMails: boolean;
|
2020-03-21 17:45:45 +00:00
|
|
|
lang: string;
|
2019-12-29 18:40:35 +00:00
|
|
|
security_question_1?: string;
|
|
|
|
security_answer_1?: string;
|
|
|
|
security_question_2?: string;
|
|
|
|
security_answer_2?: string;
|
|
|
|
|
2019-11-23 14:11:33 +00:00
|
|
|
|
|
|
|
public constructor(info : UserBuilder) {
|
2019-12-28 13:01:10 +00:00
|
|
|
for (const key in info) {
|
|
|
|
if (info.hasOwnProperty(key)) {
|
|
|
|
this[key] = info[key];
|
|
|
|
}
|
|
|
|
}
|
2019-11-23 14:11:33 +00:00
|
|
|
}
|
2020-03-21 16:16:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
get isPublic() : boolean {
|
2020-03-21 17:05:17 +00:00
|
|
|
return this.pageStatus != UserPageStatus.PRIVATE;
|
2020-03-21 16:16:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get isOpen() : boolean {
|
|
|
|
return this.pageStatus == UserPageStatus.OPEN;
|
|
|
|
}
|
2019-11-23 14:11:33 +00:00
|
|
|
|
2020-01-01 10:33:51 +00:00
|
|
|
get hasVirtualDirectory() : boolean {
|
|
|
|
return this.virtualDirectory != null
|
|
|
|
&& this.virtualDirectory != "null"
|
|
|
|
&& this.virtualDirectory.length > 0
|
|
|
|
}
|
|
|
|
|
2019-12-28 13:01:10 +00:00
|
|
|
get hasWebsite() : boolean {
|
|
|
|
return this.personnalWebsite
|
|
|
|
&& this.personnalWebsite != null
|
|
|
|
&& this.personnalWebsite.length > 0
|
|
|
|
&& this.personnalWebsite != "null"
|
|
|
|
}
|
|
|
|
|
|
|
|
get hasPublicNote() : boolean {
|
|
|
|
return this.publicNote
|
|
|
|
&& this.publicNote != null
|
|
|
|
&& this.publicNote.length > 0
|
|
|
|
&& this.publicNote != "null"
|
|
|
|
}
|
2019-12-29 18:40:35 +00:00
|
|
|
|
|
|
|
get hasSecurityQuestion1() : boolean {
|
|
|
|
return this.security_question_1 != null && this.security_question_1 && this.security_question_1.length > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
get hasSecurityAnswer1() : boolean {
|
|
|
|
return this.security_answer_1 != null && this.security_answer_1 && this.security_answer_1.length > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
get hasSecurityQuestion2() : boolean {
|
|
|
|
return this.security_question_2 != null && this.security_question_2 != null && this.security_question_2 && this.security_question_2.length > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
get hasSecurityAnswer2() : boolean {
|
|
|
|
return this.security_answer_2 != null && this.security_answer_2 && this.security_answer_2.length > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
get hasSecurityQuestions() : boolean {
|
|
|
|
return (this.hasSecurityQuestion1 && this.hasSecurityAnswer1
|
|
|
|
&& this.hasSecurityQuestion2 && this.hasSecurityAnswer2) == true;
|
|
|
|
}
|
2019-11-23 14:11:33 +00:00
|
|
|
}
|