Files
kbcrm/Client/Components/auth/models/users.ts
T

24 lines
701 B
TypeScript

import { iUserApp } from "./applications"
import { iRole } from "./roles"
export interface iUser {
id: number
userid: string
username: string
password: string
email: string
telefon: string
isSysAdmin: boolean
userapps: iUserApp[]
}
export function hasAppRole(user: iUser, appid: number, roleid: number) {
let userapp: iUserApp = user.userapps.find((userapp: iUserApp) => {return userapp.appid == appid})
if (userapp != undefined) {
let userapprole: iRole = userapp.userapp_roles.find((role: iRole) => {return role.id == roleid})
if (userapprole != undefined) {
return true
}
}
return false
}