{"version":3,"sources":["webpack:///./src/authenticatestep.ts","webpack:///./src/app.ts","webpack:///./src/app.html","webpack:///./src/callback.ts","webpack:///./src/callback.html","webpack:///./src/components/admin/admin.ts","webpack:///./src/components/admin/admin.html","webpack:///./src/auth-service.ts"],"names":["auth","run","routingContext","next","isLoggedIn","this","isAuthenticated","getAllInstructions","some","route","config","cancel","fragment","AuthenticateStep","authService","router","attached","refresh","configureRouter","options","pushState","addAuthorizeStep","map","redirect","nav","name","href","moduleId","title","roles","App","module","exports","handleAuthentication","Callback","adminService","singalrwrapper","pingmessage","ispinging","isUpdatingUnitCounts","forceRecalculation","ping","error","onPong","message","success","updateAllOrganizationUnitCounts","onAllOrganizationUnitCountsUpdated","onAllOrganizationUnitCountsUpdateFailed","loadOrganisationAdmin","on","detached","off","isSystemAdmin","isOrganisationAdmin","Admin","organizationUserService","authNotifier","_isOrganisationAdmin","auth0","domain","clientID","clientId","redirectUri","base","audience","responseType","scope","setAccessTokenRefresh","setInterval","expiresAt","JSON","parse","window","localStorage","getItem","Date","getTime","console","log","checkSession","err","result","setSession","login","savedurl","currentInstruction","endsWith","setItem","stringify","url","authorize","parseHash","authResult","accessToken","idToken","navigateTarget","navigate","emit","authenticated","idTokenExpiresAt","expiresIn","toDate","accessTokenExpiresAt","exp","logout","removeItem","returnTo","getAccessToken","claimNamespace","email","username","getOrganizationUsers","organizationUsers","length","isOrgAdmin","organizationUser","role","getOrganizationUserByEmail","items","concat","AuthService"],"mappings":"ipBAMA,aACI,WAAmBA,GAAA,KAAAA,OAgBvB,OAdI,YAAAC,IAAA,SAAIC,EAAgBC,GAChB,IAAMC,EAAaC,KAAKL,KAAKM,gBAG7B,GAAIJ,EAAeK,qBAAqBC,KAAK,SAAAC,GAAS,OAAsB,IAAtBA,EAAMC,OAAOV,QAC/D,IAAKI,EACD,OAAOD,EAAKQ,OAAO,IAAI,IAJZ,eAMZ,GAAIP,GAAcF,EAAeK,qBAAqBC,KAAK,SAAAC,GAAS,MANxD,UAMw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GAAoB,MAA0B,sBAA1BA,EAAiBC,SAEvBhH,KAAKqD,uBACnBrD,KAAKqD,qBAAuByD,GAIhC9G,KAAKqD,sBAAuB,EAGzB,CAAP,EAAOrD,KAAKqD,4BAGV,YAAAsD,qBAAN,SAA2BF,G,8FACR,SAAMzG,KAAKmD,wBAAwB8D,2BAA2BR,I,OAE7E,MAAO,CAAP,GAFM5B,EAAS,UAEDqC,OAASrC,EAAOqC,MAAML,OAAS,EACvChC,EAAOqC,MACP,UAGV,sBAAI,oBAAK,C,IAAT,WACI,MAAO,GAAGC,OAAOnH,KAAKgD,cAAgB,CAAC,YAAc,K,gCAvKhDoE,EAAW,GADvB,I,uBAiBuB,IACiB,OAjB5BA,GAAb,K","file":"app~d28f829f.9dab3f6da70b1116c09e.chunk.js","sourcesContent":["import { Redirect } from \"aurelia-router\";\r\nimport { autoinject } from \"aurelia-framework\";\r\n\r\nimport { AuthService } from \"auth-service\";\r\n\r\n@autoinject\r\nexport class AuthenticateStep {\r\n constructor(public auth: AuthService) { }\r\n\r\n run(routingContext, next) {\r\n const isLoggedIn = this.auth.isAuthenticated;\r\n const loginRoute = \"login\";\r\n\r\n if (routingContext.getAllInstructions().some(route => route.config.auth === true)) {\r\n if (!isLoggedIn) {\r\n return next.cancel(new Redirect(loginRoute));\r\n }\r\n } else if (isLoggedIn && routingContext.getAllInstructions().some(route => route.fragment === loginRoute)) {\r\n return next.cancel(new Redirect(\"home\"));\r\n }\r\n\r\n return next();\r\n }\r\n}\r\n","import { Router, RouterConfiguration } from \"aurelia-router\";\r\nimport { PLATFORM } from 'aurelia-pal';\r\nimport { AuthenticateStep } from \"authenticatestep\";\r\nimport { RolesAuthoriseStep } from \"rolesauthorisestep\";\r\nimport { AuthService } from \"auth-service\";\r\nimport { inject } from \"aurelia-framework\";\r\n\r\n@inject(\r\n AuthService\r\n)\r\nexport class App {\r\n constructor(\r\n public authService: AuthService) {\r\n }\r\n\r\n attached() {\r\n if (this.authService.isAuthenticated) {\r\n this.authService.refresh();\r\n }\r\n }\r\n\r\n router: Router = null;\r\n configureRouter(config: RouterConfiguration, router: Router) {\r\n this.router = router;\r\n config.options.pushState = true;\r\n config.addAuthorizeStep(AuthenticateStep);\r\n config.addAuthorizeStep(RolesAuthoriseStep);\r\n config.map([\r\n // unauthenticated\r\n { route: [\"\"], redirect: \"welcome\", nav: false },\r\n { route: [\"login\", \"Welcome\"], name: \"welcome\", href: \"welcome\", moduleId: PLATFORM.moduleName(\"components/welcome/welcome\"), nav: true, title: \"Welcome\" },\r\n { route: [\"support\", \"Support\"], name: \"support\", href: \"support\", moduleId: PLATFORM.moduleName(\"components/support/support\"), nav: true, title: \"Support\" },\r\n // auth0\r\n { route: 'callback', name: 'callback', moduleId: PLATFORM.moduleName(\"callback\"), nav: false },\r\n\r\n // authenticated\r\n { route: \"dashboard\", name: \"dashboard\", href: \"dashboard\", moduleId: PLATFORM.moduleName(\"components/dashboard/dashboard\"), nav: true, auth: true, title: \"Dashboard\" },\r\n { route: \"plans-and-reports\", name: \"plans-and-reports\", href: \"plans-and-reports\", moduleId: PLATFORM.moduleName(\"components/plans-and-reports/plans-and-reports\"), nav: true, auth: true, title: \"Plans and Reports\" },\r\n { route: \"manage-organizations\", name: \"manage-organizations\", href: \"manage-organizations\", moduleId: PLATFORM.moduleName(\"components/manage-organizations/manage-organizations\"), nav: true, auth: true, roles: [\"sysadmin\"], title: \"Manage Organisations\" },\r\n { route: \"manage-organization-users\", name: \"manage-organization-users\", href: \"manage-organization-users\", moduleId: PLATFORM.moduleName(\"components/manage-organization-users/manage-organization-users\"), nav: true, auth: true, title: \"User Administration\" },\r\n\r\n { route: \"plan-create\", name: \"plan-create\", href: \"plan-create\", moduleId: PLATFORM.moduleName(\"components/plan-create/plan-create\"), nav: false, auth: true, roles: [\"sysadmin\"], title: \"New Plan\" },\r\n\r\n { route: \"unit-kpi/:planid\", name: \"unit-kpi\", href: \"unit-kpi\", moduleId: PLATFORM.moduleName(\"components/unit-kpi/unit-kpi\"), nav: false, auth: true, title: \"View Unit KPI\" },\r\n { route: \"state-kpi/:planid\", name: \"state-kpi\", href: \"state-kpi\", moduleId: PLATFORM.moduleName(\"components/state-kpi/state-kpi\"), nav: false, auth: true, title: \"View State KPI\" },\r\n { route: \"zone-kpi/:planid\", name: \"zone-kpi\", href: \"zone-kpi\", moduleId: PLATFORM.moduleName(\"components/zone-kpi/zone-kpi\"), nav: false, auth: true, title: \"View Zone KPI\" },\r\n { route: \"central-kpi/:planid\", name: \"central-kpi\", href: \"central-kpi\", moduleId: PLATFORM.moduleName(\"components/central-kpi/central-kpi\"), nav: false, auth: true, title: \"View Central KPI\" },\r\n { route: \"unit-plan-view/:planid\", name: \"unit-plan-view\", href: \"unit-plan-view\", moduleId: PLATFORM.moduleName(\"components/unit-plan-view/unit-plan-view\"), nav: false, auth: true, title: \"View Unit Plan\" },\r\n { route: \"unit-plan-edit/:planid\", name: \"unit-plan-edit\", href: \"unit-plan-edit\", moduleId: PLATFORM.moduleName(\"components/unit-plan-edit/unit-plan-edit\"), nav: false, auth: true, title: \"Edit Unit Plan\" },\r\n { route: \"unit-report-view/:reportid\", name: \"unit-report-view\", href: \"unit-report-view\", moduleId: PLATFORM.moduleName(\"components/unit-report-view/unit-report-view\"), nav: false, auth: true, title: \"View Unit Report\" },\r\n { route: \"unit-report-edit/:reportid\", name: \"unit-report-edit\", href: \"unit-report-edit\", moduleId: PLATFORM.moduleName(\"components/unit-report-edit/unit-report-edit\"), nav: false, auth: true, title: \"Edit Unit Report\" },\r\n { route: \"unit-plan-copy/:planid\", name: \"unit-plan-copy\", href: \"unit-plan-copy\", moduleId: PLATFORM.moduleName(\"components/unit-plan-copy/unit-plan-copy\"), nav: false, auth: true, title: \"Copy Unit Plan\" },\r\n {\r\n route: \"unit-report-lastperiod-edit/:reportid\",\r\n name: \"unit-report-lastperiod-edit\",\r\n href: \"unit-report-lastperiod-edit\",\r\n moduleId: PLATFORM.moduleName(\"components/unit-report-lastperiod-edit/unit-report-lastperiod-edit\"),\r\n nav: false, auth: true, roles: [\"sysadmin\"], title: \"Edit Unit Report Last Period\"\r\n },\r\n\r\n { route: \"state-plan-view/:planid\", name: \"state-plan-view\", href: \"state-plan-view\", moduleId: PLATFORM.moduleName(\"components/state-plan-view/state-plan-view\"), nav: false, auth: true, title: \"View State Plan\" },\r\n { route: \"state-plan-edit/:planid\", name: \"state-plan-edit\", href: \"state-plan-edit\", moduleId: PLATFORM.moduleName(\"components/state-plan-edit/state-plan-edit\"), nav: false, auth: true, title: \"Edit State Plan\" },\r\n { route: \"state-report-view/:reportid\", name: \"state-report-view\", href: \"state-report-view\", moduleId: PLATFORM.moduleName(\"components/state-report-view/state-report-view\"), nav: false, auth: true, title: \"View State Report\" },\r\n { route: \"state-report-edit/:reportid\", name: \"state-report-edit\", href: \"state-report-edit\", moduleId: PLATFORM.moduleName(\"components/state-report-edit/state-report-edit\"), nav: false, auth: true, title: \"Edit State Report\" },\r\n { route: \"state-plan-copy/:planid\", name: \"state-plan-copy\", href: \"state-plan-copy\", moduleId: PLATFORM.moduleName(\"components/state-plan-copy/state-plan-copy\"), nav: false, auth: true, title: \"Copy State Plan\" },\r\n {\r\n route: \"state-report-lastperiod-edit/:reportid\",\r\n name: \"state-report-lastperiod-edit\",\r\n href: \"state-report-lastperiod-edit\",\r\n moduleId: PLATFORM.moduleName(\"components/state-report-lastperiod-edit/state-report-lastperiod-edit\"),\r\n nav: false, auth: true, roles: [\"sysadmin\"], title: \"Edit State Report Last Period\"\r\n },\r\n\r\n { route: \"zone-plan-view/:planid\", name: \"zone-plan-view\", href: \"zone-plan-view\", moduleId: PLATFORM.moduleName(\"components/zone-plan-view/zone-plan-view\"), nav: false, auth: true, title: \"View Zone Plan\" },\r\n { route: \"zone-plan-edit/:planid\", name: \"zone-plan-edit\", href: \"zone-plan-edit\", moduleId: PLATFORM.moduleName(\"components/zone-plan-edit/zone-plan-edit\"), nav: false, auth: true, title: \"Edit Zone Plan\" },\r\n { route: \"zone-report-view/:reportid\", name: \"zone-report-view\", href: \"zone-report-view\", moduleId: PLATFORM.moduleName(\"components/zone-report-view/zone-report-view\"), nav: false, auth: true, title: \"View Zone Report\" },\r\n { route: \"zone-report-edit/:reportid\", name: \"zone-report-edit\", href: \"zone-report-edit\", moduleId: PLATFORM.moduleName(\"components/zone-report-edit/zone-report-edit\"), nav: false, auth: true, title: \"Edit Zone Report\" },\r\n { route: \"zone-plan-copy/:planid\", name: \"zone-plan-copy\", href: \"zone-plan-copy\", moduleId: PLATFORM.moduleName(\"components/zone-plan-copy/zone-plan-copy\"), nav: false, auth: true, title: \"Copy Zone Plan\" },\r\n {\r\n route: \"zone-report-lastperiod-edit/:reportid\",\r\n name: \"zone-report-lastperiod-edit\",\r\n href: \"zone-report-lastperiod-edit\",\r\n moduleId: PLATFORM.moduleName(\"components/zone-report-lastperiod-edit/zone-report-lastperiod-edit\"),\r\n nav: false, auth: true, roles: [\"sysadmin\"], title: \"Edit Zone Report Last Period\"\r\n },\r\n\r\n { route: \"central-plan-view/:planid\", name: \"central-plan-view\", href: \"central-plan-view\", moduleId: PLATFORM.moduleName(\"components/central-plan-view/central-plan-view\"), nav: false, auth: true, title: \"View Central Plan\" },\r\n { route: \"central-plan-edit/:planid\", name: \"central-plan-edit\", href: \"central-plan-edit\", moduleId: PLATFORM.moduleName(\"components/central-plan-edit/central-plan-edit\"), nav: false, auth: true, title: \"Edit Central Plan\" },\r\n { route: \"central-report-view/:reportid\", name: \"central-report-view\", href: \"central-report-view\", moduleId: PLATFORM.moduleName(\"components/central-report-view/central-report-view\"), nav: false, auth: true, title: \"View Central Report\" },\r\n { route: \"central-report-edit/:reportid\", name: \"central-report-edit\", href: \"central-report-edit\", moduleId: PLATFORM.moduleName(\"components/central-report-edit/central-report-edit\"), nav: false, auth: true, title: \"Edit Central Report\" },\r\n { route: \"central-plan-copy/:planid\", name: \"central-plan-copy\", href: \"central-plan-copy\", moduleId: PLATFORM.moduleName(\"components/central-plan-copy/central-plan-copy\"), nav: false, auth: true, title: \"Copy Central Plan\" },\r\n {\r\n route: \"central-report-lastperiod-edit/:reportid\",\r\n name: \"central-report-lastperiod-edit\",\r\n href: \"central-report-lastperiod-edit\",\r\n moduleId: PLATFORM.moduleName(\"components/central-report-lastperiod-edit/central-report-lastperiod-edit\"),\r\n nav: false, auth: true, roles: [\"sysadmin\"], title: \"Edit Central Report Last Period\"\r\n },\r\n\r\n { route: \"organization-create\", name: \"organization-create\", href: \"organization-create\", moduleId: PLATFORM.moduleName(\"components/organization-create/organization-create\"), nav: false, auth: true, roles: [\"sysadmin\"], title: \"New Organisation\" },\r\n { route: \"organization-edit/:organizationId\", name: \"organization-edit\", href: \"organization-edit\", moduleId: PLATFORM.moduleName(\"components/organization-edit/organization-edit\"), nav: false, auth: true, title: \"Edit Organisation\" },\r\n\r\n { route: \"organization-user-create\", name: \"organization-user-create\", href: \"organization-user-create\", moduleId: PLATFORM.moduleName(\"components/organization-user-create/organization-user-create\"), nav: false, auth: true, title: \"New Organisation User\" },\r\n { route: \"organization-user-edit/:organizationUserId\", name: \"organization-user-edit\", href: \"organization-user-edit\", moduleId: PLATFORM.moduleName(\"components/organization-user-edit/organization-user-edit\"), nav: false, auth: true, title: \"Edit Organisation User\" },\r\n\r\n { route: \"admin\", name: \"admin\", href: \"admin\", moduleId: PLATFORM.moduleName(\"components/admin/admin\"), nav: true, auth: true, title: \"Admin Tools\" },\r\n\r\n { route: \"analytic-reports\", name: \"analytic-reports\", href: \"analytic-reports\", moduleId: PLATFORM.moduleName(\"components/analytic-reports/analytic-reports\"), nav: true, auth: true, title: \"Analytic Reports\" },\r\n { route: \"kpi-reports\", name: \"kpi-reports\", href: \"kpi-reports\", moduleId: PLATFORM.moduleName(\"components/kpi-reports/kpi-reports\"), nav: false, auth: true, title: \"Kpi Reports\" },\r\n { route: \"analytic-report-create\", name: \"analytic-report-create\", href: \"analytic-report-create\", moduleId: PLATFORM.moduleName(\"components/analytic-report-create/analytic-report-create\"), nav: false, auth: true, title: \"Create New Analytic Report\" },\r\n { route: \"support-auth\", name: \"support-auth\", href: \"support-auth\", moduleId: PLATFORM.moduleName(\"components/support/support\"), nav: true, auth: true, title: \"Support\" },\r\n ])\r\n }\r\n}\r\n","module.exports = \"\";","import { autoinject } from 'aurelia-framework';\r\nimport { AuthService } from 'auth-service';\r\n\r\n@autoinject\r\nexport class Callback {\r\n constructor(private auth: AuthService) {\r\n auth.handleAuthentication();\r\n }\r\n}\r\n","module.exports = \"\";","import { autoinject } from \"aurelia-framework\";\r\nimport { AuthService } from \"auth-service\";\r\nimport { AdminService } from \"services/AdminService\";\r\nimport { SignalrWrapper } from \"signalrwrapper\";\r\nimport toastr from \"toastr\";\r\n\r\n@autoinject\r\nexport class Admin {\r\n pingmessage = \"\";\r\n ispinging = false;\r\n isUpdatingUnitCounts = false;\r\n forceRecalculation = false;\r\n constructor(\r\n public adminService: AdminService,\r\n public authService: AuthService,\r\n public singalrwrapper: SignalrWrapper) {}\r\n\r\n async attached() {\r\n await this.authService.loadOrganisationAdmin();\r\n // The above needs to call first before accessing this.authService.isOrganisationAdmin\r\n\r\n this.singalrwrapper.on(\"Pong\", this.onPong);\r\n this.singalrwrapper.on(\"AllOrganizationUnitCountsUpdated\", this.onAllOrganizationUnitCountsUpdated);\r\n this.singalrwrapper.on(\"AllOrganizationUnitCountsUpdateFailed\", this.onAllOrganizationUnitCountsUpdateFailed);\r\n }\r\n\r\n detached() {\r\n this.singalrwrapper.off(\"Pong\", this.onPong);\r\n this.singalrwrapper.off(\"AllOrganizationUnitCountsUpdated\", this.onAllOrganizationUnitCountsUpdated);\r\n this.singalrwrapper.off(\"AllOrganizationUnitCountsUpdateFailed\", this.onAllOrganizationUnitCountsUpdateFailed);\r\n }\r\n\r\n ping = async () => {\r\n try {\r\n await this.adminService.ping(this.pingmessage);\r\n this.ispinging = true;\r\n } catch(error) {\r\n toastr.error(error);\r\n }\r\n }\r\n\r\n onPong = (message: string) => {\r\n toastr.success(message);\r\n this.ispinging = false;\r\n }\r\n\r\n updateAllOrganizationUnitCounts = async () => {\r\n try {\r\n await this.adminService.updateAllOrganizationUnitCounts(this.forceRecalculation);\r\n this.isUpdatingUnitCounts = true;\r\n } catch(error) {\r\n toastr.error(error);\r\n }\r\n }\r\n\r\n onAllOrganizationUnitCountsUpdated = () => {\r\n toastr.success(\"Successfully updated all organization unit counts\");\r\n this.isUpdatingUnitCounts = false;\r\n }\r\n\r\n onAllOrganizationUnitCountsUpdateFailed = (message: string) => {\r\n toastr.error(message);\r\n this.isUpdatingUnitCounts = false;\r\n }\r\n\r\n get isSystemAdmin() {\r\n return this.authService.isSystemAdmin == true;\r\n }\r\n\r\n get isOrgAdmin() {\r\n return this.authService.isOrganisationAdmin == true;\r\n }\r\n}\r\n","module.exports = \"\\r\\n\";","import { WebAuth, Auth0DecodedHash, Auth0Error } from \"auth0-js\";\r\nimport { autoinject } from \"aurelia-framework\";\r\nimport { Router } from \"aurelia-router\";\r\nimport { EventEmitter } from \"events\";\r\nimport jwtDecode from \"jwt-decode\";\r\nimport moment from \"moment\";\r\nimport env from \"./environment\";\r\nimport { OrganizationUserService } from \"services/OrganizationUserService\";\r\nimport { OrganizationUserViewModelDto } from \"models/OrganizationUserViewModelDto\";\r\n\r\nconst fiveMinuteInterval = 5 * 60 * 1000;\r\nconst fifteenMinuteInterval = 15 * 60 * 1000;\r\nconst idTokenKey = \"id_token\";\r\nconst idTokenExpiresAtKey = \"id_token_expires_at\";\r\nconst idTokenExpiresAtDateTimeKey = \"id_token_expires_at_datetime\";\r\nconst accessTokenKey = \"access_token\";\r\nconst accessTokenExpiresAtKey = \"access_token_expires_at\";\r\nconst accessTokenExpiresAtDateTimeKey = \"access_token_expires_at_datetime\";\r\nconst locationKey = \"location\";\r\nconst claimNamespace = \"https://reportingmodule.com/claims\";\r\n\r\n@autoinject\r\nexport class AuthService {\r\n\r\n authNotifier = new EventEmitter();\r\n\r\n private _isOrganisationAdmin: boolean = false;\r\n\r\n auth0 = new WebAuth({\r\n domain: env.auth0.domain,\r\n clientID: env.auth0.clientId,\r\n redirectUri: `${env.auth0.base}/callback`,\r\n audience: env.auth0.audience,\r\n responseType: \"token id_token\",\r\n scope: \"openid email\",\r\n });\r\n\r\n constructor(\r\n private router: Router,\r\n private organizationUserService: OrganizationUserService,\r\n ) {\r\n }\r\n\r\n setAccessTokenRefresh() {\r\n let timeoutId = setInterval(() => {\r\n if (this.isAuthenticated) {\r\n let expiresAt = JSON.parse(window.localStorage.getItem(accessTokenExpiresAtKey));\r\n if (expiresAt) {\r\n let currentTime = new Date().getTime();\r\n if ((expiresAt - currentTime) < fifteenMinuteInterval) {\r\n this.refresh();\r\n }\r\n }\r\n }\r\n }, fiveMinuteInterval);\r\n }\r\n\r\n refresh() {\r\n console.log('refresh token');\r\n this.auth0.checkSession({}, (err: Auth0Error, result: Auth0DecodedHash) => {\r\n if (err) {\r\n console.log(err);\r\n } else {\r\n this.setSession(result);\r\n }\r\n });\r\n }\r\n\r\n login(): void {\r\n const savedurl = this.router.currentInstruction.fragment.endsWith(\"/Welcome\") ? \"/dashboard\" : this.router.currentInstruction.fragment;\r\n window.localStorage.setItem(locationKey, JSON.stringify({ url: savedurl }));\r\n this.auth0.authorize();\r\n }\r\n\r\n handleAuthentication(): void {\r\n this.auth0.parseHash((err, authResult) => {\r\n if (authResult && authResult.accessToken && authResult.idToken) {\r\n this.setSession(authResult);\r\n \r\n const savedLocation = JSON.parse(window.localStorage.getItem(locationKey));\r\n const navigateTarget = savedLocation.url || 'dashboard';\r\n \r\n this.router.navigate(navigateTarget);\r\n \r\n this.authNotifier.emit('authChange', { authenticated: true });\r\n } else if (err) {\r\n console.log(err);\r\n }\r\n });\r\n }\r\n\r\n setSession(authResult: Auth0DecodedHash): void {\r\n this._isOrganisationAdmin = false;\r\n\r\n const idTokenExpiresAt = authResult.expiresIn * 1000 + new Date().getTime();\r\n \r\n window.localStorage.setItem(idTokenKey, authResult.idToken);\r\n window.localStorage.setItem(idTokenExpiresAtKey, JSON.stringify(idTokenExpiresAt));\r\n window.localStorage.setItem(idTokenExpiresAtDateTimeKey, JSON.stringify(moment(idTokenExpiresAt).toDate()));\r\n \r\n let decodedAccessToken: any = jwtDecode(authResult.accessToken);\r\n let accessTokenExpiresAt = decodedAccessToken.exp * 1000;\r\n window.localStorage.setItem(accessTokenKey, authResult.accessToken);\r\n window.localStorage.setItem(accessTokenExpiresAtKey, JSON.stringify(accessTokenExpiresAt));\r\n window.localStorage.setItem(accessTokenExpiresAtDateTimeKey, JSON.stringify(moment(accessTokenExpiresAt).toDate()));\r\n }\r\n\r\n get isAuthenticated(): boolean {\r\n const accessToken = window.localStorage.getItem(accessTokenKey);\r\n const expiresAt = window.localStorage.getItem(idTokenExpiresAtKey);\r\n if (!expiresAt || !accessToken)\r\n return false;\r\n \r\n const authenticated = new Date().getTime() < JSON.parse(expiresAt);\r\n return authenticated;\r\n }\r\n\r\n logout(): void {\r\n this._isOrganisationAdmin = false;\r\n\r\n window.localStorage.removeItem(accessTokenKey);\r\n window.localStorage.removeItem(idTokenKey);\r\n window.localStorage.removeItem(idTokenExpiresAtKey);\r\n window.localStorage.removeItem(idTokenExpiresAtDateTimeKey);\r\n window.localStorage.removeItem(accessTokenExpiresAtKey);\r\n window.localStorage.removeItem(accessTokenExpiresAtDateTimeKey);\r\n \r\n this.authNotifier.emit('authChange', { authenticated: false });\r\n this.auth0.logout({\r\n clientID: env.auth0.clientId,\r\n returnTo: env.auth0.returnTo\r\n });\r\n }\r\n\r\n getAccessToken(): string {\r\n const accessToken = window.localStorage.getItem(accessTokenKey);\r\n return accessToken;\r\n }\r\n\r\n get username(): string {\r\n if(!this.isAuthenticated) return;\r\n const idToken = jwtDecode(window.localStorage.getItem(idTokenKey));\r\n return idToken[`${claimNamespace}/username`]\r\n }\r\n\r\n get isSystemAdmin(): boolean {\r\n if(!this.isAuthenticated) return false;\r\n const idToken = jwtDecode(window.localStorage.getItem(idTokenKey));\r\n return idToken[`${claimNamespace}/IsSystemAdmin`]\r\n }\r\n\r\n get isOrganisationAdmin(): boolean {\r\n // loadOrganisationAdmin() needs to call first before accessing isOrganisationAdmin\r\n return this._isOrganisationAdmin;\r\n }\r\n\r\n async loadOrganisationAdmin(): Promise {\r\n if (!this.isAuthenticated) {\r\n this._isOrganisationAdmin = false;\r\n return false;\r\n }\r\n\r\n const email = this.username;\r\n const organizationUsers = await this.getOrganizationUsers(email);\r\n\r\n if (organizationUsers && organizationUsers.length > 0) {\r\n var isOrgAdmin = organizationUsers.some(\r\n organizationUser => organizationUser.role === 'OrganisationAdmin'\r\n );\r\n if (isOrgAdmin != this._isOrganisationAdmin) {\r\n this._isOrganisationAdmin = isOrgAdmin;\r\n }\r\n }\r\n else {\r\n this._isOrganisationAdmin = false;\r\n }\r\n\r\n return this._isOrganisationAdmin;\r\n }\r\n\r\n async getOrganizationUsers(email: string): Promise {\r\n const result = await this.organizationUserService.getOrganizationUserByEmail(email);\r\n\r\n return result.items && result.items.length > 0\r\n ? result.items\r\n : [];\r\n }\r\n \r\n get roles(): string[] {\r\n return [].concat(this.isSystemAdmin ? [\"sysadmin\"] : []);\r\n }\r\n}\r\n"],"sourceRoot":""}