If you are passing additional attributes via the SSO attributes and you want to save these attributes to the data source you need some code to get these attributes an save it to the data source.
As a reminder you this is the documentation for our SSO configuration: Single Sign-on with SAML2 | Fliplet Developers Documentation
Roughly speaking the steps are the following:
- Using the login hook as a trigger to get the list of attributes
- Connect to the login DS to get the entry ID of the logged in user
- Update the users record with the SSO attributes.
The following sample code needs to be on the screen with the SSO login component. Please add this to screen JS.
//Change the data source ID the SSO login component is connected to
let loginDataSource = 123456;
Fliplet.Hooks.on("login", function (formEntry) {
return Fliplet.User.getCachedSession().then(function (session) {
var user = _.get(session, "entries.saml2.user");
if (!user) {
return;
}
//Open the console and see what data has been returned by the SSO
console.log(user);
return Fliplet.DataSources.connect(loginDataSource).then(function (
connection
) {
return connection
.findOne({
where: { Email: user.email },
})
.then(function (record) {
return Fliplet.DataSources.connect(loginDataSource).then(function (
connection
) {
return connection.update(record.id, {
// Here is the attributes that you need to map. The format is the following: "column in the data source": "attribute from SSO"
//In this case Job Title is in the data source and the SSO attribute is jobTitle. The attributes can be seen on the console.
'Job Title': user.jobTitle,
Office: user.office
});
});
});
});
});
});