This project is read-only.

Return different views depending on user?

Topics: Troubleshooting, Writing modules
Feb 12, 2012 at 10:22 AM


i got a problem that i can´t figure out, is it possible to in my controller se if a user is authenticated and if its true return one view and return another view if the user not is authenticated? If it possible can someone point me in the right direction.

Feb 13, 2012 at 12:43 AM

Yes, you can get the http context, the look at the current user and check if it's authenticated. Then return a different view result with a different view name based on this.

Feb 13, 2012 at 5:42 PM

If your controller, injet an IOrchardServices instance named _orchardServices. Then in your controller, you can get the currently authenticated user with _orchardServices.WorkContext.CurrentUser. If it's null the user is not authenticated.

Feb 13, 2012 at 8:16 PM

thx you both for the input! realy helped me out!