How can I restrict some screens to only be accessible to admins using a security rule?
You can use the following custom security rule. You will need to change the screen ID of the screen where you want the user to be taken to if a non admin tries to access a admin screen.
The screen names need to start with ‘Admin’ for e.g. ‘Admin - Dashboard’
var menuScreen = 123456;
var hasSession = session && session.entries && session.entries.dataSource;
var isAdmin = hasSession && session.entries.dataSource.data['Admin'] === 'Yes';
var isAdminPage = page.title.indexOf('Admin') === 0;
var error = false;
if (isAdminPage && !isAdmin) {
error = true;
}
if (isAdmin) {
error = false;
}
if (error && page.id !== menuScreen) {
navigate = { action: 'screen', page: menuScreen, transition: 'slide.left' };
}
There’s more documentation available on custom code for security rules at Securing your apps | Fliplet Developers Documentation