What is the best way to write a custom security rule

We have used the following 2 codes snippets in our custom screen security condition, within the app settings of two different apps. I’m wondering if there is one that is better? Which one should we be using?

var loginSSO = #####;
var loginEmail = ####;

var isAllowed =
(session && session.entries && session.entries.dataSource) ||
(session && session.entries && session.entries.saml2) ||
( page.id === loginSSO ||
page.id === loginEmail);

if (page.id !== loginSSO && !isAllowed) {
error = true;
navigate = { action: ‘screen’, page: loginSSO, transition: ‘slide.left’ };
}

var loginSSO = ####;
var IoginEmail = ####;

var isAllowed =
(session && session.entries && session.entries.dataSource) ||
(session && session.entries && session.entries.saml2) ||
(page.id === loginSSO ||
page.id === IoginEmail);

if (!isAllowed) {
error = true;
navigate = { action: ‘screen’, page: loginSSO, transition: ‘slide.left’ };
}

Hi Catalina,

I would use the first version over the second. The reason is that the first one will ensure you are not stuck on an infinite loop if you visit the SSO screen.

Thanks,
Deb