/// <summary> /// Inspects the environment and checks to see if this is a POST containing the HTML form fields in the login.html page. /// </summary> /// <param name="environment"></param> /// <param name="formsAuthenticationProvider"></param> public LoginContext(IDictionary<string, object> environment, FormsAuthenticationProvider formsAuthenticationProvider) { _environment = environment; Request = new OwinRequest(environment); Response = new OwinResponse(environment); _formsAuthenticationProvider = formsAuthenticationProvider; _responseStream = Response.Body; var requestContentType = Request.GetHeader("Content-Type"); _isFormUrlEncodedPost = Request.Method == "POST" && !string.IsNullOrEmpty(requestContentType) && requestContentType.StartsWith("application/x-www-form-urlencoded"); if (_isFormUrlEncodedPost && Request.Body != null) { _formData = Request.ReadForm().Result; var username = _formData["login_username"]; var password = _formData["login_password"]; var rememberMe = _formData["remember_me"] != null && _formData["remember_me"] == "yes"; if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password)) { environment["formsauthn.username"] = username; environment["formsauthn.password"] = password; environment["formsauthn.remember"] = rememberMe; } } }
public OwinRequestMessage(OwinRequest request) : base(request.Body, request.GetHeader(HawkConstants.ContentTypeHeaderName)) { this.request = request; }