public LoginActionResult(IViewService viewSvc, IDictionary<string, object> env, LoginViewModel model)
     : base(async () => await viewSvc.Login(env, model))
 {
     if (viewSvc == null) throw new ArgumentNullException("viewSvc");
     if (env == null) throw new ArgumentNullException("env");
     if (model == null) throw new ArgumentNullException("model");
 }
 public virtual Task<System.IO.Stream> Login(IDictionary<string, object> env, LoginViewModel model)
 {
     return Render(model, "login");
 }
        private async Task<IHttpActionResult> RenderLoginPage(string errorMessage = null, string username = null)
        {
            var ctx = Request.GetOwinContext();
            var providers =
                from p in ctx.Authentication.GetAuthenticationTypes(d => d.Caption.IsPresent())
                select new LoginPageLink{ Text = p.Caption, Href = Url.Route(Constants.RouteNames.LoginExternal, new { provider = p.AuthenticationType }) };

            if (errorMessage != null)
            {
                Logger.InfoFormat("rendering login page with error message: {0}", errorMessage);
            }
            else
            {
                Logger.Info("rendering login page");
            }

            var loginModel = new LoginViewModel
            {
                SiteName = _options.SiteName,
                SiteUrl = ctx.Environment.GetIdentityServerBaseUrl(),
                CurrentUser = await GetNameFromPrimaryAuthenticationType(), 
                ExternalProviders = providers,
                AdditionalLinks = _authenticationOptions.LoginPageLinks,
                ErrorMessage = errorMessage,
                LoginUrl = Url.Route(Constants.RouteNames.Login, null),
                Username = username
            };

            return new LoginActionResult(_viewService, ctx.Environment, loginModel);
        }