File

src/app/models/user.model.ts

Index

Properties
Methods

Constructor

constructor(cfg?: IUser)
Parameters :
Name Type Optional
cfg IUser yes

Methods

isInAtLeastOneRole
isInAtLeastOneRole(roles: string[])
Parameters :
Name Type Optional
roles string[] no
Returns : boolean
isInRole
isInRole(role: string)
Parameters :
Name Type Optional
role string no
Returns : boolean
isInRoles
isInRoles(roles: string[])
Parameters :
Name Type Optional
roles string[] no
Returns : boolean

Properties

accounts
accounts: BankAccount[]
Type : BankAccount[]
address
address: Address
Type : Address
currentTheme
currentTheme: string
Type : string
customerId
customerId: string
Type : string
defaultFlexPayView
defaultFlexPayView: string
Type : string
domain
domain: string
Type : string
emailAddress
emailAddress: string
Type : string
financialInstitutionId
financialInstitutionId: string
Type : string
firstName
firstName: string
Type : string
foreignKey
foreignKey: string
Type : string
gPinKey
gPinKey: string
Type : string
hasAcceptedDisclaimer
hasAcceptedDisclaimer: boolean
Type : boolean
hasGoogleAuth
hasGoogleAuth: boolean
Type : boolean
id
id: string
Type : string
isEnrolled
isEnrolled: boolean
Type : boolean
isForcePasswordChange
isForcePasswordChange: boolean
Type : boolean
isPasswordExpired
isPasswordExpired: boolean
Type : boolean
isPictureTipsHidden
isPictureTipsHidden: boolean
Type : boolean
lastName
lastName: string
Type : string
links
links: string[]
Type : string[]
password
password: string
Type : string
phoneNumbers
phoneNumbers: string[]
Type : string[]
pinEnabled
pinEnabled: boolean
Type : boolean
roles
roles: string[]
Type : string[]
userName
userName: string
Type : string
import { Address, BankAccount } from './';
import { IUser } from './i-user.model';

export class User {
  currentTheme: string;
  customerId: string;
  defaultFlexPayView: string;
  domain: string;
  emailAddress: string;
  financialInstitutionId: string;
  firstName: string;
  foreignKey: string;
  gPinKey: string;
  hasAcceptedDisclaimer: boolean;
  hasGoogleAuth: boolean;
  id: string;
  isEnrolled: boolean;
  isForcePasswordChange: boolean;
  isPasswordExpired: boolean;
  isPictureTipsHidden: boolean;
  lastName: string;
  links: string[];
  password: string;
  phoneNumbers: string[];
  pinEnabled: boolean;
  roles: string[];
  userName: string;
  address: Address;
  accounts: BankAccount[];

  constructor(cfg?: IUser) {
    if (!cfg) {
      this.userName = 'anonymous_user';
      this.roles = [];
      return;
    }

    this.currentTheme = cfg.currentTheme;
    this.customerId = cfg.customerId;
    this.defaultFlexPayView = cfg.defaultFlexPayView;
    this.domain = cfg.domain;
    this.emailAddress = cfg.emailAddress;
    this.financialInstitutionId = cfg.financialInstitutionId;
    this.firstName = cfg.firstName;
    this.foreignKey = cfg.foreignKey;
    this.gPinKey = cfg.gPinKey;
    this.hasAcceptedDisclaimer = cfg.hasAcceptedDisclaimer;
    this.hasGoogleAuth = cfg.hasGoogleAuth;
    this.id = cfg.id;
    this.isEnrolled = cfg.isEnrolled;
    this.isForcePasswordChange = cfg.isForcePasswordChange;
    this.isPasswordExpired = cfg.isPasswordExpired;
    this.isPictureTipsHidden = cfg.isPictureTipsHidden;
    this.lastName = cfg.lastName;
    this.links = cfg.links;
    this.password = cfg.password;
    this.phoneNumbers = cfg.phoneNumbers;
    this.pinEnabled = cfg.pinEnabled;
    this.roles = cfg.roles;
    this.userName = cfg.userName;
    this.address = cfg.address;
    this.accounts = cfg.accounts;
  }

  isInRole(role: string): boolean {
    let matched = this.roles.filter(r => r === role);
    return matched.length > 0;
  }

  isInRoles(roles: string[]): boolean {
    let matches = roles
      .map(role => {
        return this.isInRole(role);
      })
      .filter(b => b);
    return matches.length === roles.length;
  }

  isInAtLeastOneRole(roles: string[]): boolean {
    let matches = roles
      .map(role => {
        return this.isInRole(role);
      })
      .filter(b => b);
    return matches.length > 0;
  }
}

results matching ""

    No results matching ""