componentAccessValidation method
bool
componentAccessValidation(
- BuildContext context,
- AccessDetermined accessDetermined,
- AppModel currentApp,
- String component,
- String id,
- dynamic model,
Implementation
bool componentAccessValidation(
BuildContext context,
AccessDetermined accessDetermined,
AppModel currentApp,
String component,
String id,
dynamic model) {
try {
// if model is not found then no access for this member
if (model == null) {
print('$component with id $id not found');
return false;
}
// if no conditions set then access for this member
if (model.conditions == null) return true;
if (model.conditions!.privilegeLevelRequired == null) return true;
// if access is set to no priv required then access for this member, i.e. blocked members can see public pages
if (model.conditions!.privilegeLevelRequired ==
PrivilegeLevelRequiredSimple.noPrivilegeRequiredSimple) return true;
// if access is not set and blocked member then no access for this member
if ((accessDetermined is LoggedIn) &&
(accessDetermined.isCurrentAppBlocked(currentApp.documentID))) {
return false;
}
// Given some privilege is required and access is not set then no access for this member
if (accessDetermined is! LoggedIn) return false;
if (model.conditions!.privilegeLevelRequired == null) return true;
// If sufficient privilege set then access for this member
if (model.conditions!.privilegeLevelRequired!.index <=
accessDetermined
.getPrivilegeLevelCurrentApp(currentApp.documentID)
.index) return true;
// If no sufficient privileges then no access for this member
return false;
} catch (_) {
print('Exception whilst validating access to $component with id $id');
return false;
}
}