use of io.jmix.ui.accesscontext.UiShowScreenContext in project jmix by jmix-framework.
the class UserActionsButtonImpl method initUserMenuButton.
protected void initUserMenuButton(boolean authenticated) {
MenuBar.MenuItem userMenuButton = component.addItem("");
userMenuButton.setDescription(messages.getMessage("userActionsBtnDescription"));
userMenuButton.setIcon(getIconResource(JmixIcon.USER));
userMenuButton.setVisible(authenticated);
UiShowScreenContext showScreenContext = new UiShowScreenContext("settings");
accessManager.applyRegisteredConstraints(showScreenContext);
if (showScreenContext.isPermitted()) {
userMenuButton.addItem(messages.getMessage("settings"), getIconResource(JmixIcon.GEAR), item -> openSettings());
}
userMenuButton.addItem(messages.getMessage("logoutBtnDescription"), getIconResource(JmixIcon.SIGN_OUT), item -> logout());
}
use of io.jmix.ui.accesscontext.UiShowScreenContext in project jmix by jmix-framework.
the class JmixApp method routeTopLevelWindowId.
@Override
protected String routeTopLevelWindowId() {
if (isAnonymousAuthentication()) {
String screenId = uiProperties.getLoginScreenId();
if (!windowConfig.hasWindow(screenId)) {
screenId = uiProperties.getMainScreenId();
}
String initialScreenId = uiProperties.getInitialScreenId();
if (Strings.isNullOrEmpty(initialScreenId)) {
return screenId;
}
if (!windowConfig.hasWindow(initialScreenId)) {
log.info("Initial screen '{}' is not found", initialScreenId);
return screenId;
}
UiShowScreenContext context = new UiShowScreenContext(initialScreenId);
accessManager.applyRegisteredConstraints(context);
if (!context.isPermitted()) {
log.info("Initial screen '{}' is not permitted", initialScreenId);
return screenId;
}
return initialScreenId;
} else {
return uiProperties.getMainScreenId();
}
}
use of io.jmix.ui.accesscontext.UiShowScreenContext in project jmix by jmix-framework.
the class UrlChangeHandler method shouldRedirect.
public boolean shouldRedirect(WindowInfo windowInfo) {
if (ui.hasAuthenticatedSession()) {
return false;
}
boolean allowAnonymousAccess = uiProperties.isAllowAnonymousAccess();
UiShowScreenContext showScreenContext = new UiShowScreenContext(windowInfo.getId());
accessManager.applyRegisteredConstraints(showScreenContext);
return !allowAnonymousAccess || !showScreenContext.isPermitted();
}
use of io.jmix.ui.accesscontext.UiShowScreenContext in project jmix by jmix-framework.
the class UrlChangeHandler method isPermittedToNavigate.
public boolean isPermittedToNavigate(NavigationState requestedState, WindowInfo windowInfo) {
UiShowScreenContext showScreenContext = new UiShowScreenContext(windowInfo.getId());
accessManager.applyRegisteredConstraints(showScreenContext);
if (!showScreenContext.isPermitted()) {
revertNavigationState();
throw new AccessDeniedException("screen", windowInfo.getId());
}
NavigationFilter.AccessCheckResult navigationAllowed = navigationAllowed(requestedState);
if (navigationAllowed.isRejected()) {
if (isNotEmpty(navigationAllowed.getMessage())) {
showNotification(navigationAllowed.getMessage());
}
revertNavigationState();
return false;
}
return true;
}
use of io.jmix.ui.accesscontext.UiShowScreenContext in project jmix by jmix-framework.
the class ScreensHelper method getDefaultBrowseScreen.
@Nullable
public WindowInfo getDefaultBrowseScreen(MetaClass metaClass) {
WindowInfo browseWindow = windowConfig.findWindowInfo(windowConfig.getBrowseScreenId(metaClass));
if (browseWindow != null) {
UiShowScreenContext screenContext = new UiShowScreenContext(browseWindow.getId());
accessManager.applyRegisteredConstraints(screenContext);
if (screenContext.isPermitted()) {
return browseWindow;
}
}
WindowInfo lookupWindow = windowConfig.findWindowInfo(windowConfig.getLookupScreenId(metaClass));
if (lookupWindow != null) {
UiShowScreenContext screenContext = new UiShowScreenContext(lookupWindow.getId());
accessManager.applyRegisteredConstraints(screenContext);
if (screenContext.isPermitted()) {
return lookupWindow;
}
}
return null;
}
Aggregations