public void SetUserPrincipal(string authorization) { User user; using (var context = new RecipesContext()){ var userRepo = new UserRepository(context); user = userRepo.GetUserByAccessToken(authorization); } UserIdentity identity = null; if (user != null && user.AccessTokenExpiry > DateTime.UtcNow) { identity = new UserIdentity(user); } if (identity != null) { SetPrincipal(new UserPrincipal(identity)); } }
public UserPrincipal(UserIdentity identity) { this.identity = identity; }