IHttpActionResult AuthorizeError(AuthorizeError error) { if (error.ErrorType == ErrorTypes.User) { var env = Request.GetOwinEnvironment(); var errorModel = new ErrorViewModel { SiteName = _options.SiteName, SiteUrl = env.GetIdentityServerBaseUrl(), CurrentUser = User.GetName(), ErrorMessage = LookupErrorMessage(error.Error) }; var errorResult = new ErrorActionResult(_viewService, env, errorModel); return(errorResult); } var query = new NameValueCollection { { "error", error.Error } }; if (error.State.IsPresent()) { query.Add("state", error.State); } var url = error.ErrorUri.AbsoluteUri; if (error.ResponseMode == Constants.ResponseModes.Query || error.ResponseMode == Constants.ResponseModes.FormPost) { url = url.AddQueryString(query.ToQueryString()); } else { url = url.AddHashFragment(query.ToQueryString()); } Logger.Info("Redirecting to: " + url); return(Redirect(url)); }
IHttpActionResult AuthorizeError(AuthorizeError error) { if (error.ErrorType == ErrorTypes.User) { var env = Request.GetOwinEnvironment(); var errorModel = new ErrorViewModel { SiteName = _options.SiteName, SiteUrl = env.GetIdentityServerBaseUrl(), CurrentUser = User.GetName(), ErrorMessage = error.Error }; var errorResult = new ErrorActionResult(_viewService, env, errorModel); return(errorResult); } else { string character; if (error.ResponseMode == Constants.ResponseModes.Query || error.ResponseMode == Constants.ResponseModes.FormPost) { character = "?"; } else { character = "#"; } var url = string.Format("{0}{1}error={2}", error.ErrorUri.AbsoluteUri, character, error.Error); if (error.State.IsPresent()) { url = string.Format("{0}&state={1}", url, error.State); } Logger.Info("Redirecting to: " + url); return(Redirect(url)); } }
private void AssertErrorReturnsRequestValues(AuthorizeError error, ValidatedAuthorizeRequest request) { error.ResponseMode.Should().Be(request.ResponseMode); error.ErrorUri.Should().Be(request.RedirectUri); error.State.Should().Be(request.State); }
private void AssertErrorReturnsRequestValues(AuthorizeError error, ValidatedAuthorizeRequest request) { Assert.AreEqual(request.ResponseMode, error.ResponseMode); Assert.AreEqual(request.RedirectUri, error.ErrorUri); Assert.AreEqual(request.State, error.State); }
IHttpActionResult AuthorizeError(AuthorizeError error) { if (error.ErrorType == ErrorTypes.User) { var env = Request.GetOwinEnvironment(); var errorModel = new ErrorViewModel { SiteName = _options.SiteName, SiteUrl = env.GetIdentityServerBaseUrl(), CurrentUser = User.GetName(), ErrorMessage = error.Error }; var errorResult = new ErrorActionResult(_viewService, env, errorModel); return errorResult; } else { string character; if (error.ResponseMode == Constants.ResponseModes.Query || error.ResponseMode == Constants.ResponseModes.FormPost) { character = "?"; } else { character = "#"; } var url = string.Format("{0}{1}error={2}", error.ErrorUri.AbsoluteUri, character, error.Error); if (error.State.IsPresent()) { url = string.Format("{0}&state={1}", url, error.State); } Logger.Info("Redirecting to: " + url); return Redirect(url); } }
public AuthorizeErrorResult(AuthorizeError error) { _error = error; }
private void AssertErrorReturnsRequestValues(AuthorizeError error, ValidatedAuthorizeRequest request) { Assert.AreEqual(request.ResponseMode, error.ResponseMode); Assert.AreEqual(request.RedirectUri, error.ErrorUri); Assert.AreEqual(request.State, error.State); }
public static IHttpActionResult AuthorizeError(this ApiController controller, AuthorizeError error) { return(new AuthorizeErrorResult(error)); }