Hi - I’m getting an error message with a custom security script: SyntaxError: Unexpected number
I’m trying to redirect users after login to three different screens based on their classification in one column from the datasource. Can anyone help me with the code?
\if ActiveFree then freeMenu
\if ActivePaid then paidMenu
\if Expired then subscription
var freeMenu = 453215;
var subscription = 453456;
var paidMenu 248884;
var hasSession = session && session.entries && session.entries.dataSource;
var isActiveFree = hasSession && session.entries.dataSource.data[‘Access’] === ‘Active Free’;
var isActivePaid = hasSession && session.entries.dataSource.data[‘Access’] === ‘Active Paid’;
var isExpired = hasSession && session.entries.dataSource.data[‘Access’] === ‘Expired’;
var error = false;
if ((isActiveFree && hasSession) ||(isActivePaid && hasSession) ||(isExpired && hasSession)){
error = false;
}
if (!isActiveFree || !isActivePaid || !isExpired){
var freeMenu = 453215;
var subscription = 453456;
var paidMenu = 248884;
var hasSession = session && session.entries && session.entries.dataSource;
var isActiveFree = hasSession && session.entries.dataSource.data['Access'] === 'Active Free';
var isActivePaid = hasSession && session.entries.dataSource.data['Access'] === 'Active Paid';
var isExpired = hasSession && session.entries.dataSource.data['Access'] === 'Expired';
var error = false;
if ((isActiveFree && hasSession) ||(isActivePaid && hasSession) ||(isExpired && hasSession)){
error = false;
}
if (!isActiveFree || !isActivePaid || !isExpired){
error = true;
}
if (isActiveFree){
navigate = { action: 'screen', page: freeMenu, transition: 'slide.left' };
}
if (isActivePaid){
navigate = { action: 'screen', page: paidMenu, transition: 'slide.left' };
}
if (isActivePaid){
navigate = { action: 'screen', page: subscription, transition: 'slide.left' };
}
as a custom condition for App security. So simply you need to remove the first 4 lines of your code including calling customRedirect function on line 4. Also, don’t forget to remove the closing function bracket ‘}’ on the last line of your code.