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
Post a Comment