Require Login to view catalog

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 năm cách đây
I have put together a site with additional views(pages) What I am needing to do is only allow non-logged in accounts to view just the front pages and not get access to the catalog at all without being signed in.

I am using 2.3 and cannot seem to think of the best way to do this
12 năm cách đây
Hi Scripter,
Did you have any success with this?

I'm new to nopCommerce and MVC so if you have managed to pull this off, a code example would be amazing.

Thanks,
DB
12 năm cách đây
Hi,

I think this is very easy.

Just add this statement in the beginning of the Category Controller:

if (_workContext.CurrentCustomer.IsRegistered())
{
     return View("YourView");
}
12 năm cách đây
Hi c523,  thank you for the response!

I unsuccessfully tried to apply your idea to the categorynavigation.cshtml which appeared to have the potential to hide the category view from a non-registered user.   I realize this is probably not how I was supposed to interpret your suggestion.

When you say at the beginning of the Category Controller, do you mean in the constructors region of the  CategoryController.cs file?

Your idea makes a lot of sense, I'm just not sure where to put it exactly.  

Thanks again for your help.
12 năm cách đây
Try it in the Category controller and not the view I think that is where you need to aply the change not 100% but worth testing...
12 năm cách đây
Hi DB,

The Category Controller is in \Presentation\Nop.Web\Controllers\CatalogController.cs. Place it at the beginning of this action:
public ActionResult Category(int categoryId, CatalogPagingFilteringModel command)
{
   //place the code here..

}
3 năm cách đây
Does it work in Nop 4.20?
If not, can anyone show me how to do it?

Thanks
3 năm cách đây
Yes, It will work for Nop 4.20 as well.
If you want to redirect your customer to login page then use return Challenge();
instead to explicitly mentioning the view.
Here is what you have to do,
3 năm cách đây
FYI, there are some things you can 'hide' using the Access Control List  (uncheck Guests)

Public store. Allow navigation          
Public store. Display Prices          
Public store. Enable shopping cart          
Public store. Enable wishlist
3 năm cách đây
rmahbub63 wrote:
Yes, It will work for Nop 4.20 as well.
If you want to redirect your customer to login page then use return Challenge();
instead to explicitly mentioning the view.
Here is what you have to do,


Thank you so much. Your solution resolved my question!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.