src/lib/model/eo-user.model.ts
Properties |
|
Methods |
|
constructor(json: any)
|
||||||||
Defined in src/lib/model/eo-user.model.ts:86
|
||||||||
Creates a new instance
Parameters :
|
Public deputies |
deputies:
|
Type : any[]
|
Defined in src/lib/model/eo-user.model.ts:67
|
List of the users deputies |
Public email |
email:
|
Type : string
|
Defined in src/lib/model/eo-user.model.ts:39
|
The users email address |
Public firstname |
firstname:
|
Type : string
|
Defined in src/lib/model/eo-user.model.ts:27
|
The users firstname |
Public id |
id:
|
Type : string
|
Defined in src/lib/model/eo-user.model.ts:19
|
The users ID |
Public imageUri |
imageUri:
|
Type : string
|
Defined in src/lib/model/eo-user.model.ts:47
|
URI to the users avatar image |
Public lastname |
lastname:
|
Type : string
|
Defined in src/lib/model/eo-user.model.ts:31
|
The users lastname |
Public name |
name:
|
Type : string
|
Defined in src/lib/model/eo-user.model.ts:23
|
The users name |
Public passwortvalidation |
passwortvalidation:
|
Type : any
|
Defined in src/lib/model/eo-user.model.ts:75
|
Password validation settings |
Public present |
present:
|
Type : boolean
|
Defined in src/lib/model/eo-user.model.ts:43
|
Flag indicating whether or not the user is present |
Public privileges |
privileges:
|
Type : Privileges[]
|
Defined in src/lib/model/eo-user.model.ts:59
|
List of the users privileges |
Public roles |
roles:
|
Type : any[]
|
Defined in src/lib/model/eo-user.model.ts:63
|
List of roles the user belongs to |
Public substitutesOf |
substitutesOf:
|
Type : any[]
|
Defined in src/lib/model/eo-user.model.ts:71
|
List of the users substitutes |
Public title |
title:
|
Type : string
|
Defined in src/lib/model/eo-user.model.ts:35
|
The users title (generated from backends title pattern) |
Public userSettings |
userSettings:
|
Type : any
|
Defined in src/lib/model/eo-user.model.ts:51
|
Custom user settings |
Public getClientLocale |
getClientLocale()
|
Defined in src/lib/model/eo-user.model.ts:170
|
Gets the users configured client locale
Returns :
string
locale string |
Public getSchemaLocale |
getSchemaLocale()
|
Defined in src/lib/model/eo-user.model.ts:178
|
Gets the users configured schema locale
Returns :
string
locale string |
hasPrivilege | ||||||||
hasPrivilege(privilege: string)
|
||||||||
Defined in src/lib/model/eo-user.model.ts:126
|
||||||||
Checks if the user has a certain privilege
Parameters :
Returns :
boolean
True if the user has this particular privilege, false otherwise |
hasRole | ||||||||
hasRole(role: string)
|
||||||||
Defined in src/lib/model/eo-user.model.ts:144
|
||||||||
Checks if the user has a certain role
Parameters :
Returns :
boolean
True if the user has this particular role, false otherwise |
Public setImageBase | ||||||||
setImageBase(base: string)
|
||||||||
Defined in src/lib/model/eo-user.model.ts:160
|
||||||||
adds the base path for the users image path.
Parameters :
Returns :
void
|
export interface Privileges {
id: string;
type: string;
name: string;
}
export interface LicenseState {
type: string;
error?: string;
expires?: string;
}
export class EoUser {
/**
* The users ID
*/
public id: string;
/**
* The users name
*/
public name: string;
/**
* The users firstname
*/
public firstname: string;
/**
* The users lastname
*/
public lastname: string;
/**
* The users title (generated from backends title pattern)
*/
public title: string;
/**
* The users email address
*/
public email: string;
/**
* Flag indicating whether or not the user is present
*/
public present: boolean;
/**
* URI to the users avatar image
*/
public imageUri: string;
/**
* Custom user settings
*/
public userSettings: any;
/**
* @ignore
*/
public schema: any;
/**
* List of the users privileges
*/
public privileges: Privileges[];
/**
* List of roles the user belongs to
*/
public roles: any[];
/**
* List of the users deputies
*/
public deputies: any[];
/**
* List of the users substitutes
*/
public substitutesOf: any[];
/**
* Password validation settings
*/
public passwortvalidation: any;
/**
* @ignore
*/public schemaLocale: string;
/**
* @ignore
*/
public uiDirection: string;
/**
* @ignore
*/
public license: LicenseState;
/**
* Creates a new instance
* @param json The JSON object received from the backend. This will be used to construct the new user instance
*/
constructor(json: any) {
const jUser = json['user'];
const jSchema = json['schema'];
this.id = jUser.id;
this.name = jUser.name;
this.firstname = jUser.firstname;
this.lastname = jUser.lastname;
this.title = jUser.title;
this.email = jUser.email;
this.present = jUser.present;
if (jUser.hasimage === true) {
this.imageUri = '/organization/image/' + this.id;
}
this.userSettings = typeof json['usersettings'] === 'object' ? json['usersettings'] : {};
this.schema = {
version: jSchema.version,
supportedLocales: jSchema.supportedlocales
};
this.privileges = jUser.privileges;
this.roles = jUser.effectiveroles;
this.deputies = jUser.deputies || [];
this.substitutesOf = jUser.substitutesOf || [];
this.schemaLocale = jUser.locale;
this.license = json['license'];
}
/**
* Checks if the user has a certain privilege
* @param privilege The privilege to be checked
* @returns True if the user has this particular privilege, false otherwise
*/
hasPrivilege(privilege: string): boolean {
let match = false;
if (this.privileges) {
let i = 0;
while (!match && i < this.privileges.length) {
match = this.privileges[i].name === privilege;
i++;
}
}
return match;
}
/**
* Checks if the user has a certain role
* @param role The role to be checked
* @returns True if the user has this particular role, false otherwise
*/
hasRole(role: string): boolean {
let match = false;
if (this.roles) {
let i = 0;
while (!match && i < this.roles.length) {
match = this.roles[i].name === role;
i++;
}
}
return match;
}
/**
* adds the base path for the users image path.
* @param base The base path
*/
public setImageBase(base: string) {
if (this.imageUri) {
this.imageUri = base + this.imageUri;
}
}
/**
* Gets the users configured client locale
* @returns locale string
*/
public getClientLocale(): string {
return this.userSettings['clientlocale'];
}
/**
* Gets the users configured schema locale
* @returns locale string
*/
public getSchemaLocale(): string {
return this.schemaLocale;
}
}