public static void SetLoggedUserInfo(HttpContextBase httpContext) { if (httpContext.User != null && httpContext.User.Identity.IsAuthenticated) { LoggedUserInfo info = GetUserInfoFromDB(httpContext.User.Identity.Name); if (info == null) { SignOutUser(httpContext); } else { httpContext.User = CreateUserPrincipal(info); } } }
public UserPrincipal(IIdentity identity, LoggedUserInfo userInfo) : base(identity, userInfo.Roles) { UserInfo = userInfo; }
private static UserPrincipal CreateUserPrincipal(LoggedUserInfo user) { var identity = new UserIdentity("DB", true, user.Login); return(new UserPrincipal(identity, user)); }