Getting user/session details utilizing 365 SSO instead of fliplet datasource

Can I ask, how would you use this approach while utilizing MS365 Sign on approach?

obviously using

wont work, however how should this be altered to enable showing content based on user’s login details? i tried doing this:

Fliplet.User.getCachedSession().then(function (session) {
var user = _.get(session, ‘entries.saml2.data’);

if (user === ‘xxx@xxx.com’){
$(’.fl-widget-instance.IT-user’).attr(‘style’,‘display: block !important’);
}

});

but to no avail.
Any ideas?

thanks
Greg

P.S. how do i format code nicely on the forum?

If you are singing on using SSO then you can use the snippet you mentioned.

Fliplet.User.getCachedSession().then(function (session) {
var user = _.get(session, 'entries.saml2.data');
console.log(user)
if (user.email === 'xxx@xxx.com'){
$('.fl-widget-instance.IT-user').attr('style','display: block !important');
}

});

You can see the data returned by the SSO in the console and then hide/show the item you would like using jQuery.

PS: if you want to format code nicely then use tripe quotes before and after the code block.

When I use code you have provided, I get this error:

Uncaught SyntaxError: Invalid or unexpected token

Try again, It was likely due to formatting issue with the quotes around strings.

Nope, tried messing with code bits, but nothing helps

in console im also getting following errors:

‘’‘Uncaught SyntaxError: Invalid or unexpected token
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘email’)
at preview?auth_token=eu–session–2cd6320c6118e69314d753b0398206dc-498-152-1212&interact=false&disableSecurity:1555’’’

Any other ideas what can be causing this issue? Without being able to retrieve username while logging in with SSO, the whole point of my app becomes redundant.

I would first confirm that the SSO authentication is successful:

Use this code:

If you don’t see the data returned by SSO then you need to either expose data on the SSO side or SSO is not setup correctly.

Once you have verified the above then we use the returned variables to hide/show items.

I am getting an object return and in the console there are expected properties i.e. email. still doesnt work…

OK thats great!

So what logic are you trying to use? and what are you trying to hide and show exactly?

This, and it doesnt work

@GregS what does the console.log(user) output shows you? Does it contain the properties you are looking for?

You can also try logging the whole SAML2 returned object via console.log(_.get(session, 'entries.saml2')) to confirm what it contains.

It does indeed, but when trying to access them, its just not playing ball.
seebelow:

INteresting, when i try your sugestion either exactly as you submitted or with saml2.data it just returns undefined. but when I do console.log(user); I actually get the object as shown in the above screenshot

@GregS have you tried following the documentation here? Single Sign-on with SAML2 | Fliplet Developers Documentation

See this sample code:

Fliplet.User.getCachedSession().then(function (session) {
  var user = _.get(session, 'entries.saml2.user');

  if (!user) {
    return; // user is not logged in with saml2
  }

  // user contains "firstName", "lastName" and "email"

  // create a welcome string
  var text = `You are signed in as ${user.email}.`;

  // display it in a html element with class "welcome"
  $('.welcome').text(text);
});

I haven’t actually, thank you for providing it. I admit I find documentation difficult to navigate as even search does not bring meaningful results…

SOLVED: This actually solves my issue, thank you so much

Hi Greg

What were you searching for? We’ll review the results.

Anything really. I find Fliplet, as a framework/solution to be great and have massive potential, however, as soon as i need to customize something and using simple html/CSS/JS doesn’t work, searching through knowledgebase and documentation is just painful. thing always seem to be only half explained and often fragmented. Then again, it might just be me.

Is it ok if we reach out for a brief call? I’d love to get your feedback and suggestions so we can discuss them internally. I’ll message you.

of course it is