Ok so finally after some blood, sweat and tears I finally fixed our SAML integration issue on mendix hybrid applications. My issue was 2 fold:
var mxMobile = {};
mxMobile.enableSamlLogin = function() {
var register = function(){
if (window.dojoConfig.ui.customLoginFn && typeof(window.dojoConfig.ui.customLoginFn) == 'function') {
console.log('enableSamlLogin: config.ui.customLoginFn available');
window.dojoConfig.ui.customLoginFn();
} else {
console.log('enableSamlLogin: config.ui.customLoginFn NOT available');
}
}
mxMobile.waitForDojoConfig(register);
}
mxMobile.waitFor = function(fnCondition, succesCallback, errorCallBack, timeoutMs, interval) {
var waitTime = 0;
var id = setInterval(function() {
waitTime += interval;
if (waitTime > timeoutMs) {
clearInterval(id);
errorCallBack();
return;
}
if (fnCondition()) {
clearInterval(id);
succesCallback();
return;
}
}, interval);
}
mxMobile.waitForDojoConfig = function(fnCallback) {
mxMobile.waitFor(function() {
return window.dojoConfig;
}, function() {
console.log("enableSamlLogin: dojoConfig available");
fnCallback();
}, function() {
console.log("enableSamlLogin: dojoConfig not created");
}, 60000, 10);
}
mxMobile.enableSamlLogin();
Hope this helps someone in the future!
Schalk, I implemented this code in our application to get SAML working on mobile for a custom login page as well. It did resolve the issue with the mobile app and SAML logins are now working.
One question though – in my browser console I am seeing the following error:
HTMLSnippet_widget_HTMLSnippet_0.postCreate
mxui.js?636928216015980052:67 HTMLSnippet_widget_HTMLSnippet_0._setupEvents
mxui.js?636928216015980052:67 HTMLSnippet_widget_HTMLSnippet_0.executeCode
mxui.js?636928216015980052:67 HTMLSnippet_widget_HTMLSnippet_1.postCreate
mxui.js?636928216015980052:67 HTMLSnippet_widget_HTMLSnippet_1._setupEvents
mxui.js?636928216015980052:67 HTMLSnippet_widget_HTMLSnippet_1.executeCode
mxui.js?636928216015980052:67 HTMLSnippet_widget_HTMLSnippet_1.evalJS
mxui.js?636928216015980052:67 JDEAccountSync.AnonymousLogIn.dataView5: fetching object through microflow 'JDEAccountSync.DS_LogIn'
mxui.js?636928216015980052:67 enableSamlLogin: dojoConfig available
mxui.js?636928216015980052:67 TypeError: Cannot read property 'customLoginFn' of undefined
at register (HTMLSnippet_widget_HTMLSnippet_1.js:5)
at eval (HTMLSnippet_widget_HTMLSnippet_1.js:38)
at eval (HTMLSnippet_widget_HTMLSnippet_1.js:27)
HTMLSnippet_widget_HTMLSnippet_1.js:5 Uncaught TypeError: Cannot read property 'customLoginFn' of undefined
at register (HTMLSnippet_widget_HTMLSnippet_1.js:5)
at eval (HTMLSnippet_widget_HTMLSnippet_1.js:38)
at eval (HTMLSnippet_widget_HTMLSnippet_1.js:27)
mxui.js?636928216015980052:67 JDEAccountSync.AnonymousLogIn.dataView5: received 1 objects
[e]
mxui.js?636928216015980052:67 HTMLSnippet_widget_HTMLSnippet_0.update
mxui.js?636928216015980052:67 HTMLSnippet_widget_HTMLSnippet_0._executeCallback from update
mxui.js?636928216015980052:67 HTMLSnippet_widget_HTMLSnippet_1.update
mxui.js?636928216015980052:67 HTMLSnippet_widget_HTMLSnippet_1._executeCallback from update
From my interpretation, the window.dojoconfig object is created and the enableSAMLLogin function is called, but when it tries to evaluate the
if (window.dojoConfig.ui.customLoginFn && typeof(window.dojoConfig.ui.customLoginFn) == 'function')
test, it fails. Are you also seeing this on your custom login page?