diff --git a/app/ayanova/src/utils/auth.js b/app/ayanova/src/utils/auth.js
index 1cfdad35..9e67b04b 100644
--- a/app/ayanova/src/utils/auth.js
+++ b/app/ayanova/src/utils/auth.js
@@ -17,6 +17,47 @@ const ACCESS_TOKEN_KEY = "access_token";
// domain: CLIENT_DOMAIN
// });
+
+//https://stackoverflow.com/questions/15551652/javascript-enum-flag-check
+const AuthorizationRoles =
+ {
+
+ ///No role set
+ NoRole = 0,
+ ///BizAdminLimited
+ BizAdminLimited = 1,
+ ///BizAdminFull
+ BizAdminFull = 2,
+ ///DispatchLimited
+ DispatchLimited = 4,
+ ///DispatchFull
+ DispatchFull = 8,
+ ///InventoryLimited
+ InventoryLimited = 16,
+ ///InventoryFull
+ InventoryFull = 32,
+ ///AccountingFull
+ AccountingFull = 64,//No limited role, not sure if there is a need
+ ///TechLimited
+ TechLimited = 128,
+ ///TechFull
+ TechFull = 256,
+ ///SubContractorLimited
+ SubContractorLimited = 512,
+ ///SubContractorFull
+ SubContractorFull = 1024,
+ ///ClientLimited
+ ClientLimited = 2048,
+ ///ClientFull
+ ClientFull = 4096,
+ ///OpsAdminLimited
+ OpsAdminLimited = 8192,
+ ///OpsAdminFull
+ OpsAdminFull = 16384
+
+ }//end AuthorizationRoles
+
+
export function login() {
// auth.authorize({
// responseType: 'token id_token',
@@ -102,3 +143,15 @@ function isTokenExpired(token) {
const expirationDate = getTokenExpirationDate(token);
return expirationDate < new Date();
}
+
+//================ ROLES =================
+export function hasRole(role) {
+
+ if ((role & flags.ERROR) == flags.ERROR){
+ alert("ERROR IS SET");
+ }
+
+ const idToken = getIdToken();
+ return !!idToken && !isTokenExpired(idToken);
+ }
+