1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2025-06-21 00:55:17 +00:00

Can check out wheter user has setup security questions or not

This commit is contained in:
2019-12-29 19:40:35 +01:00
parent 5b6ad59486
commit 4297cabd7e
4 changed files with 71 additions and 6 deletions

View File

@ -12,7 +12,9 @@ export enum UserPageStatus {
OPEN
}
export interface UserBuilder {
export interface UserInfo {
id: number,
firstName: string,
lastName: string,
@ -27,12 +29,20 @@ export interface UserBuilder {
allowPostsFromFriends: boolean,
}
export interface SecuritySettings {
id: number,
security_question_1 ?: string,
security_answer_1 ?: string,
security_question_2 ?: string,
security_answer_2 ?: string
}
export interface UserBuilder extends UserInfo, SecuritySettings {
}
export class User implements UserBuilder {
friendsListPublic: boolean;
personnalWebsite?: string;
publicNote?: string;
blockComments: boolean;
allowPostsFromFriends: boolean;
id: number;
firstName: string;
lastName: string;
@ -40,6 +50,16 @@ export class User implements UserBuilder {
virtualDirectory: string;
pageStatus: UserPageStatus;
accountImage: AccountImage;
friendsListPublic: boolean;
personnalWebsite?: string;
publicNote?: string;
blockComments: boolean;
allowPostsFromFriends: boolean;
security_question_1?: string;
security_answer_1?: string;
security_question_2?: string;
security_answer_2?: string;
public constructor(info : UserBuilder) {
for (const key in info) {
@ -62,4 +82,27 @@ export class User implements UserBuilder {
&& this.publicNote.length > 0
&& this.publicNote != "null"
}
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;
}
}