Redirect to login page from driver

Topics: Troubleshooting, Writing modules
Jul 26, 2012 at 9:58 AM

Hi, I have a custom content part containing a reference to the userpart. I only want to display the content items that "belong" to the referenced userpart by comparing it to the currently logged in user. How do I go about doing this?

Should it return some sort of redirect-to-login from the driver or from the part handler?

Jul 26, 2012 at 1:43 PM

Not sure I'm following. Seems like a fairly straghtforward query to make through ContentManager.

Jul 26, 2012 at 2:35 PM

Yes the query is straight forward and the business logic is done, I only need to know how to redirect to the login page once I have found the result of this query to the ContentManager. Sorry, in retrospect I see that my question can easily be misunderstood, but the title of the post should have been self explanitory.

Jul 26, 2012 at 3:54 PM
Edited Jul 26, 2012 at 4:01 PM

Ah, yes, I had read the question and not the title. Happens all the time.

The easiest way to send the user to the login page is to return new HttpUnauthorizedResult() from your controller action.

Ah but you also said "from driver". Ah well, I think throwing OrchardSecurityException should do the trick from anywhere if I'm not mistaken.

Jul 26, 2012 at 4:29 PM

Thanks you were right.