Password Protected Feature

We have to add password protected feature for a domain. Since the account is multidomain we cannot directly enable the password protect feature of website record.
So we can the password protect feature by creating an extension to redirect the user from the home page to the new page with Login Button. The new page will be a landing page created using SMT.

//using header profile view
_.extend(HeaderProfileView.prototype, {
getContext: _.wrap(HeaderProfileView.prototype.getContext, function (fn) {
var originalRet = fn.apply(this, _.toArray(arguments).slice(1));
console.log('originalRet1', originalRet.showLoginMenu);
if (originalRet.showLoginMenu == true) {
var currenturl = window.location.href;
var flag = true;
if (currenturl != '/newlogin') {
flag = false;
}
if ((flag == false)) {
console.log("flag", flag);
var newLandingPageUrl = '/newlogin';
window.location.href = newLandingPageUrl;
}

}

return originalRet;

})
});


// using profile model
var profile = ProfileModel.ProfileModel ? ProfileModel.ProfileModel.getInstance() : ProfileModel.getInstance();
setTimeout(function () {
var islogged = profile.attributes.isLoggedIn;
if (islogged == 'F') {
var currenturl = window.location.href;
var currentPage = currenturl.split('/').pop(-1);
currentPage = currentPage.split('.');
var flag = true;
if (currentPage[0] != 'newlogin'&&currentPage[0] != 'checkout') {
flag = false;
}
if ((flag == false)) {
var newLandingPageUrl = '/newlogin';
window.location.href = newLandingPageUrl;
}
}
}, 1000);
}

}

Leave a comment

Your email address will not be published. Required fields are marked *