Login Page Customisation

We can block customer login access from a particular website by extending the Account.Model file

_.extend(AccountModel,{
  login: _.wrap(AccountModel.login, function(fn) {
  var context = fn.apply(this, _.toArray(arguments).slice(1));
	if(context) {
	var giveAccess;
        var customFields = nlapiGetWebContainer().getShoppingSession().getCustomer().getCustomFieldValues();
        var string_customFields = JSON.stringify(customFields, null, 2);
        var website = JSON.parse(string_customFields);
        giveAccess = website[0].value; 
	   if (giveAccess != 1) {
            var user = Profile.get();
            user.isLoggedIn = ModelsInit.session.isLoggedIn2() ? 'T' : 'F';
            user.isRecognized = ModelsInit.session.isRecognized() ? 'T' : 'F';
			}else{
		throw new Error('You have no access to this website. Please enter a valid email and password');
			}
                       }
	return context;
		})
	});	

Leave a comment

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