Hi, which function does [Authenticate] attribute call in mvc controller?
have CustomUserSession and CustomAuthProvider.
when i goto [Authenticate] actions in mvc, will return to login page without hit any function in custom user session or custom auth provider.
UserController : BaseController : ServiceStackController<CustomUserSession>
and action
[Authenticate]
public ActionResult Index(){}
any idea?
mythz
2
The [Authenticate]
attribute is executed by the [ExecuteServiceStackFilters]
MVC Filter attribute which calls the IsAuthorized() extension method:
if (!ssController.IsAuthorized(authAttr))
{
//...
}
Which just checks to see the user has a valid Session with IsAuthenticated=true
:
public static bool IsAuthorized(this IHasServiceStackProvider hasProvider, AuthenticateAttribute authAttr)
{
if (authAttr == null)
return true;
var authSession = hasProvider.ServiceStackProvider.GetSession();
return authSession != null && authSession.IsAuthenticated;
}
You always give me an answer in time, thanks.