Reputation: 310
It's my First question here so i apologize for my english :)
we are building MVC 4 application with authentication made by Jasig CAS SSO.
It works pretty good but i need to do custom action after authentication of user.
Steps should look like:
action 5. is run only once after successful logon! every next request skips this step.
I have read documentation of CAS and MSDN about forms authentication but i couldn't any information.
I found that i could extend AuthorizeAttribute and override AuthorizeCore method but it is ran every request.
thanks for help
Upvotes: 0
Views: 360
Reputation: 310
I found answer by myself. Maybe there are better resolutions but this one makes what i wanted.
To make some custom action after logon in Jasig CAS you need to implement
protected void Application_PreRequestHandlerExecute(object sender, EventArgs e)
in Global.asax
sample code:
protected void Application_PreRequestHandlerExecute(object sender, EventArgs e)
{
//must check if user is authenticated (this method can be called before authentication)
if (Context.User.Identity.IsAuthenticated && Context.Session != null && Context.Session["IsLogged"] == null)
{
Context.Session.Add("YourKey", YourData);
Context.Session.Add("IsLogged", true);
}
}
Probably the same approach could be used in standard forms authentication if needed
Upvotes: 0