From aae765a6e9973dd7c6c6d37e64b487e09c907a34 Mon Sep 17 00:00:00 2001 From: Olmo del Corral Cano Date: Wed, 10 Jul 2019 10:51:32 +0200 Subject: [PATCH] replace AllowAnonymous for SignumAllowAnonymous --- Signum.React.Extensions/Authorization/AuthClient.tsx | 2 +- Signum.React.Extensions/Authorization/AuthController.cs | 6 +++--- Signum.React.Extensions/Authorization/AuthTokensServer.cs | 4 ++-- Signum.React.Extensions/Translation/CulturesController.cs | 7 ++++--- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Signum.React.Extensions/Authorization/AuthClient.tsx b/Signum.React.Extensions/Authorization/AuthClient.tsx index 82328a09e6..f24047ba12 100644 --- a/Signum.React.Extensions/Authorization/AuthClient.tsx +++ b/Signum.React.Extensions/Authorization/AuthClient.tsx @@ -325,7 +325,7 @@ export function loginWindowsAuthentication(): Promise { au && console.log("loginWindowsAuthentication"); return au; - }); + }).catch(() => undefined); } function getCookie(name: string) { diff --git a/Signum.React.Extensions/Authorization/AuthController.cs b/Signum.React.Extensions/Authorization/AuthController.cs index 2bc9c54422..367e996e11 100644 --- a/Signum.React.Extensions/Authorization/AuthController.cs +++ b/Signum.React.Extensions/Authorization/AuthController.cs @@ -17,7 +17,7 @@ namespace Signum.React.Authorization [ValidateModelFilter] public class AuthController : ControllerBase { - [HttpPost("api/auth/login"), AllowAnonymous] + [HttpPost("api/auth/login"), SignumAllowAnonymous] public ActionResult Login([Required, FromBody]LoginRequest data) { if (string.IsNullOrEmpty(data.userName)) @@ -85,7 +85,7 @@ public LoginResponse LoginFromApiKey(string apiKey) return new LoginResponse { message = message, userEntity = UserEntity.Current, token = token }; } - [HttpPost("api/auth/loginFromCookie"), AllowAnonymous] + [HttpPost("api/auth/loginFromCookie"), SignumAllowAnonymous] public LoginResponse? LoginFromCookie() { using (ScopeSessionFactory.OverrideSession()) @@ -101,7 +101,7 @@ public LoginResponse LoginFromApiKey(string apiKey) } } - [HttpPost("api/auth/loginWindowsAuthentication"), AllowAnonymous] + [HttpPost("api/auth/loginWindowsAuthentication"), Authorize, SignumAllowAnonymous] public LoginResponse? LoginWindowsAuthentication() { using (ScopeSessionFactory.OverrideSession()) diff --git a/Signum.React.Extensions/Authorization/AuthTokensServer.cs b/Signum.React.Extensions/Authorization/AuthTokensServer.cs index ece4c86eed..45858e8f82 100644 --- a/Signum.React.Extensions/Authorization/AuthTokensServer.cs +++ b/Signum.React.Extensions/Authorization/AuthTokensServer.cs @@ -33,7 +33,7 @@ public static void Start(Func tokenConfig, strin SignumAuthenticationFilter.Authenticators.Add(InvalidAuthenticator); } - public static SignumAuthenticationResult InvalidAuthenticator(FilterContext actionContext) + public static SignumAuthenticationResult? InvalidAuthenticator(FilterContext actionContext) { throw new AuthenticationException("No authentication information found!"); } @@ -50,7 +50,7 @@ public static SignumAuthenticationResult InvalidAuthenticator(FilterContext acti public static SignumAuthenticationResult? AllowAnonymousAuthenticator(FilterContext actionContext) { if (actionContext.ActionDescriptor is ControllerActionDescriptor cad && - (cad.MethodInfo.HasAttribute() || cad.ControllerTypeInfo.HasAttribute())) + (cad.MethodInfo.HasAttribute() || cad.ControllerTypeInfo.HasAttribute())) return new SignumAuthenticationResult(); return null; diff --git a/Signum.React.Extensions/Translation/CulturesController.cs b/Signum.React.Extensions/Translation/CulturesController.cs index af96282cce..79cf8c839a 100644 --- a/Signum.React.Extensions/Translation/CulturesController.cs +++ b/Signum.React.Extensions/Translation/CulturesController.cs @@ -17,6 +17,7 @@ using System.ComponentModel.DataAnnotations; using System.Net; using Microsoft.AspNetCore.Http; +using Signum.React.Authorization; namespace Signum.React.Translation { @@ -29,19 +30,19 @@ public CultureController(IHostingEnvironment env) _env = env; } - [HttpGet("api/culture/cultures"), AllowAnonymous] + [HttpGet("api/culture/cultures"), SignumAllowAnonymous] public List GetCultures() { return CultureInfoLogic.CultureInfoToEntity.Value.Values.ToList(); } - [HttpGet("api/culture/currentCulture"), AllowAnonymous] + [HttpGet("api/culture/currentCulture"), SignumAllowAnonymous] public CultureInfoEntity CurrentCulture() { return CultureInfo.CurrentCulture.TryGetCultureInfoEntity() ?? CultureInfoLogic.CultureInfoToEntity.Value.Values.FirstEx(); } - [HttpPost("api/culture/setCurrentCulture"), AllowAnonymous] + [HttpPost("api/culture/setCurrentCulture"), SignumAllowAnonymous] public string SetCurrentCulture([Required, FromBody]Lite culture) { var ci = ExecutionMode.Global().Using(_ => culture.Retrieve().ToCultureInfo());