Overriding the login post method of customer controller version 4.40

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hace 1 año
I wrote yidna's answer but it doesn't work in nopCommerce 4.6

in visual studio in debug mode , my custom login method not called and default login method ( in customer controller) called !!

anyone has any recommend ?
Hace 1 año
I just checked and it works fine

Did you register the controller in your NopStartup.cs

        /// <summary>
        /// Add and configure any of the middleware
        /// </summary>
        /// <param name="services">Collection of service descriptors</param>
        /// <param name="configuration">Configuration of the application</param>
        public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
        {
            services.AddScoped<CustomerController, CustomCustomerController>();
        }
Hace 1 año
Thanks Yidna , I registered my controller in nopstart and its worked!
I did not know that we should register controllers too
Hace 1 año
What I found out is that we just  inherit CustomCustomerController from CustomController and override the base Login method and cause of C# rules, we can not use our custom model (ex:
CustomOtpLoginModel
)  in Login method in our CustomCustomer contoller. Anyone has any idea that how we should override
/Login
route to our custom route because method overriding is not route changing.

I tried to use RouteProvider and set new address for /Login but it did not work

endpointRouteBuilder.MapControllerRoute(name: "MyCustomConfigurationRouteName",
            pattern: "Login",
            defaults: new { controller = "MyCustomController", action = "MyCustomMethod"});
Hace 1 año
You could use  a Customer View Engine to load your own Version of Login.cshtml
Which has a different Model
Copy the Current Factory model prepare routine and create your own factory to build the modified Model
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.