static void setCurrentUser(IKernel container, IPipelines pipelines, NancyContext context) { NancyContextAuthInfo info = context.GetBasicUserPassword(); if (!string.IsNullOrWhiteSpace(info.UserName)) { using (IUserRepository repo = container.Get<IUserRepository>()) { User user = repo.GetByUserName(info.UserName); if (user != null) { if (string.CompareOrdinal(user.Password, info.Password) != 0) { user.Claims.Clear(); } context.CurrentUser = user; } } } }