import { Role } from '.' ; import { isRole , IUser } from './User' ; export interface ILoggedInUser { id : number ; organizationId : number ; email : string ; blockchainAccountAddress : string ; rights : number ; hasRole ( ... role ) : boolean ; ownerId : string ; hasOrganization : boolean ; } export class LoggedInUser implements ILoggedInUser { constructor ( user ) { this . id = user . id ; this . organizationId = user . organization ?. id ; this . email = user . email ; this . blockchainAccountAddress = user . organization ?. blockchainAccountAddress ; this . rights = user . rights ; } id : number ; organizationId : number ; email : string ; blockchainAccountAddress : string ; rights : number ; hasRole ( ... role ) { return isRole ( this , ... role ) ; } get ownerId ( ) : string { return ( this . organizationId ?? this . id ) . toString ( ) ; } get hasOrganization ( ) : boolean { return ! ! this . organizationId ; } }