Adding extra step to ASP.NET MVC authentication -


i have mvc 5 website running using standard forms authentication.

however need add step user's login process. once user has been authenticated whether or not have access multiple offices. if need show them list of offices , must choose one.

this mandatory step , cannot considered logged on until it.

do need create our own authentication or should add check basecontroller?

you can extend implementation of built-in authentication:

public class officeselectionauthorizeattribute : authorizeattribute {     protected override bool authorizecore(httpcontextbase httpcontext)     {         var result = base.authorizecore(httpcontext);          if (result)         {             if (isofficeselected())             {                 return true;             }              httpcontext.response.redirecttoroute("officeselection route");             httpcontext.response.flush();         }          return false;     }      private bool isofficeselected()     {         //office selection check     } } 

then need use filter instead of default one:

[officeselectionauthorize] public class accountcontroller : controller {     //action methods } 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -