Override the default SignIn view/controller (Users/Account/LogOn) using a custom module???

Topics: Core, Customizing Orchard, Writing modules
Jan 27, 2013 at 10:18 PM


Is it possible to override the default SignIn view/controller (Users/Account/LogOn) with a custom module?

On a default Orchard website (core), there is a SignIn link on the bottom of the page, click it then bring you to the /Users/Account/Logon page.

What we try to do is to write a custom module to override this behavior:

1. Instead of go to that default Logon link, it should go to our custom module view say:

/MyModule/Account/Logon ;

2. It should use the custom logon logic instead of the default one.

How can we do that in a custom module?


Jan 28, 2013 at 6:46 PM

Any idea?

Jan 28, 2013 at 7:04 PM

Yes, you can override the templates that link to login/signin so that they render URL's that point to your own custom controller. Define routes for your controller in your module's Routes.cs. 

Jan 29, 2013 at 2:27 PM

Having done this quite extensively (creating some sort of hybrid mess) with one of our module then yes it is possible. But that was mostly done between Orchard 0.9 and 1.1 and kept going with our business logic to the current 1.6 version. Im curious now if I could just replace it completely with something more simple now I know my way around a lot better. 

In its simplest you should be able to create an alternate of the login shape and change the route that is created for the form post. Re-render the login shape if that fails validation or something in the controller. Hmm here we've created our own shape rather than an alternate, maybe that wasn't possible when I created my module (I'll try checking if that is possible again some point) . 

Our main problem to get around was to login with just a email - just a subscription kind of thing, then feeding them passwords only if they needed access to admin areas / restricted areas. Similarly changing the views for when a person registers but without a password etc.

You can change the default un-authorized url in the Orchard.Web Web.config file:

<authentication mode="Forms">
      <forms loginUrl="~/Users/Account/AccessDenied" timeout="2880"/>

Provide your own route if you like. Our module create a simple one: "~/Login". 99% Ive just kept it as above, as if they are unauthorized they are likely requiring access which doesn't need custom logic, but follow the default one ie to the admin or a section of admin. The rest of the work would be changing links and things in the themes and possibly any profile modules to your login path.

I'm curious of your scenario though. What are you trying to achieve that isn't there with the default login / register views?

Hope that gets you started at least.


Jan 9, 2015 at 7:18 PM
Edited Jan 9, 2015 at 7:19 PM
Hi, I realize this post is a couple of years old but I am faced with the same situation and wonder if you could share some information on how you accomplished this. We are trying to use orchard as the main site that validates user credentials against a different internal system. Then store their credentials as session variables. I have an aspx page that accomplish this, I just can't figure out how to convert it to the MVC architecture and merge it with Orchard.
Jan 13, 2015 at 11:34 AM
You have to create a module and override IMembershipService to do this. You can look for examples in the Orchard gallery, there's some modules to connect Orchard to LDAP/AD.
Apr 15, 2015 at 7:26 AM
Hello Friends , I have A quesion , i idon't know how to change admin url login, its www.yoursite.com/admin/ by default i want to chagne admin to other address how to change it, thanks.