actionHasAccess method
Future<bool>
actionHasAccess(
- ActionModel action
)
Implementation
Future<bool> actionHasAccess(ActionModel action) async {
var appID = action.app.documentID;
if (action.conditions != null) {
var theAccess = accesses[appID];
if ((theAccess != null) &&
(!AccessHelper.displayConditionOk(
theAccess.packageConditionsAccess,
action.conditions!,
getPrivilegeLevel(appID),
memberIsOwner(appID),
isBlocked(appID),
isLoggedIn()))) return false;
}
if (action is GotoPage) {
var theAccess = accesses[appID];
if (theAccess == null) return false;
var pageID = action.pageID;
var access = theAccess.pagesAccess[pageID];
if (access == null) {
access = (await pageRepository(appId: action.app.documentID)!
.get(pageID, onError: (_) {}) !=
null);
theAccess.pagesAccess[pageID] = access;
return access;
}
return access;
} else if (action is OpenDialog) {
var theAccess = accesses[appID];
if (theAccess == null) return false;
var dialogID = action.dialogID;
var access = theAccess.dialogsAccess[dialogID];
if (access == null) {
access = (await dialogRepository(appId: action.app.documentID)!
.get(dialogID, onError: (_) {}) !=
null);
theAccess.dialogsAccess[dialogID] = access;
return access;
}
return access;
} else if (action is PopupMenu) {
var access = false;
for (var item in action.menuDef!.menuItems!) {
var hasAccess = await menuItemHasAccess(item);
if (hasAccess) access = true;
}
/*
action.menuDef!.menuItems!.forEach((item) async {
var hasAccess = await menuItemHasAccess(item);
if (hasAccess) access = true;
});
*/
return access;
} else if (action is InternalAction) {
if (action.internalActionEnum == InternalActionEnum.login) {
return !isLoggedIn();
} else if (action.internalActionEnum == InternalActionEnum.logout) {
return isLoggedIn();
} else if (action.internalActionEnum == InternalActionEnum.goHome) {
return true;
} else if (action.internalActionEnum == InternalActionEnum.otherApps) {
return hasAccessToOtherApps();
}
return true;
}
return true;
}