I have implemented custom method for making user information available to Views with smth like that:
protected override void OnAuthorization(AuthorizationContext filterContext)
{
if (HttpContext.User != null)
{
HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];
if (authCookie != null)
{
FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value);
JavaScriptSerializer serializer = new JavaScriptSerializer();
AWESOMEUser user = serializer.Deserialize<AWESOMEUser>(authTicket.UserData);
if (user == null)
{
HttpContext.User = null;
}
else
{
HttpContext.User = new PlatformUser(typeof(DBMembershipProvider).Name, user);
}
}
else
{
HttpContext.User = null;
}
}
base.OnAuthorization(filterContext);
}
The problem is when user information (especially permissions) are changed in DB it is not reflected in Views. Shall I just update it on every call here on there is smarter way, i.e. other method which helps to update user information automatically?