tags:

views:

42

answers:

2

If a user is logged in and the ChangePasswordRequired flag is set, i need to disregard the current action and redirect them to the ChangePassword action.

In other words, I do not want the user to be able to do anything until he or she changes his or her password.

Which method should my base controller override and how should I handle the redirect?

+1  A: 

I would use an actionfilter that you add to every controller class that should implement this behaviour. You can read some more on at this blog post by Phil Haack

Robban
+2  A: 

You should create your own action filter.

The exact type of action filter you want to use is one that implements IAuthorizationFilter and the method you want to use it the OnAuthorizing() or close. This filter type is executed before all the others.

Instead of the [Authorize] filter you would use your own filter. Be sure to make your flag check and whether the user is authenticated (Request.IsAuthenticated)

Kindness,

Dan

Daniel Elliott
if i go this route do i have to decorate every actionresult method with my filter attribute or can i just decorate my base controller with it?What would be the difference with what you suggested and with overriding the OnActionExecuting and changing the ActionResult there?
Jonas Stawski