Sunday, 15 June 2014

Adding extra step to ASP.NET MVC authentication -


I have an MVC 5 website using standard form authentication.

However, after I authenticate the steps for an additional user's login process, we see if they have access to multiple offices or not. If they need us to show them a list of offices and they have to choose one.

This is a mandatory step and they can not be considered as logical as long as they do so.

Do we need to make our own authentication or should I add a check to the basin controller?

You can extend the implementation of the underlying authentication:

  Public Sector OfficeSelectionAuthorizeAttribute: AuthorizeAttribute {Safe Override bool AuthorizeCore (HttpContextBase httpContext) {var results = base.AuthorizeCore (httpContext); If (result) {if (IsOfficeSelected ()) {back true; } HttpContext.Response.RedirectToRoute ("OfficeSelection Route"); HttpContext.Response.Flush (); }          return false; } Personal Bull IOOffice Selected () {// Office Selection Check}}  

Then you have to use this filter instead of default:

  [OfficeSelectionAuthorize ] Public Class Account Controller: Controller {// Action Methods}  

No comments:

Post a Comment