JS error?

Hello again

I have come across a weird problem. After you guys helped me set up everything correctly with SSO, everything was working as I needed it to. However, I had only single page enforcing the rule of “only show content if such and such person is logged in (pulling data from the SSO)”.

I went to the page to literally just copy that JS code and reuse it on the other pages I needed. When I did that, that feature stopped working?? on that page. I tried it on another and again, wasn’t working. Here is the code I have used so far:

Fliplet.User.getCachedSession().then(function(session) {
var user = _.get(session, ‘entries.saml2.user’);
if (user.email != ‘xxx@xxx.com’ || ‘yyy@xxx.com’) {
$(’.html.no-touchevents.js-focus-visible .focus-outline-active, html.no-touchevents.js-focus-visible
.focus-outline’).attr(‘style’,‘display: none’);

Worth noting, that what is targeted here:

$('.html.no-touchevents.js-focus-visible .focus-outline-active, html.no-touchevents.js-focus-visible .focus-outline').attr('style','display: none');

Doesn’t really matter, because I narrowed down the issue to the fact that even though **user.email** fetches correct data, if statement seems to be just omitted and the style gets applied no matter who is logged in.

What have I missed this time?

EDIT: I also tried other way arround:

if (user.email === ‘xxx@xxx.com’ || ‘yyy@xxx.com’) {
$(’.html.no-touchevents.js-focus-visible .focus-outline-active, html.no-touchevents.js-focus-visible
.focus-outline’).attr(‘style’,‘display: block’);

Worth noting that the CSS is also applied dependably on which option I used, if first one than the CSS is set to:

html.no-touchevents.js-focus-visible .focus-outline-active, html.no-touchevents.js-focus-visible .focus-outline{
display: block;

otherwise is set to none.

!important has also been used and doesn’t seem to mean anything. Whatever is in JS, that gets set no matter what.

If anyone needs it in the future, the answer it this:

if (user.email === ‘xxx@xxx.com’ || ‘yyy@xxx.com’)

should be

if (user.email === ‘xxx@xxx.com’ || user.email === ‘yyy@xxx.com’)

Great work on resolving the issue yourself Greg!

1 Like