Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
replace AllowAnonymous for SignumAllowAnonymous
Browse files Browse the repository at this point in the history
  • Loading branch information
olmobrutall committed Jul 10, 2019
1 parent 3ecc538 commit aae765a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Signum.React.Extensions/Authorization/AuthClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ export function loginWindowsAuthentication(): Promise<AuthenticatedUser | undefi
return API.loginWindowsAuthentication().then(au => {
au && console.log("loginWindowsAuthentication");
return au;
});
}).catch(() => undefined);
}

function getCookie(name: string) {
Expand Down
6 changes: 3 additions & 3 deletions Signum.React.Extensions/Authorization/AuthController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<LoginResponse> Login([Required, FromBody]LoginRequest data)
{
if (string.IsNullOrEmpty(data.userName))
Expand Down Expand Up @@ -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())
Expand All @@ -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())
Expand Down
4 changes: 2 additions & 2 deletions Signum.React.Extensions/Authorization/AuthTokensServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static void Start(Func<AuthTokenConfigurationEmbedded> 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!");
}
Expand All @@ -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<AllowAnonymousAttribute>() || cad.ControllerTypeInfo.HasAttribute<AllowAnonymousAttribute>()))
(cad.MethodInfo.HasAttribute<SignumAllowAnonymousAttribute>() || cad.ControllerTypeInfo.HasAttribute<SignumAllowAnonymousAttribute>()))
return new SignumAuthenticationResult();

return null;
Expand Down
7 changes: 4 additions & 3 deletions Signum.React.Extensions/Translation/CulturesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using System.ComponentModel.DataAnnotations;
using System.Net;
using Microsoft.AspNetCore.Http;
using Signum.React.Authorization;

namespace Signum.React.Translation
{
Expand All @@ -29,19 +30,19 @@ public CultureController(IHostingEnvironment env)
_env = env;
}

[HttpGet("api/culture/cultures"), AllowAnonymous]
[HttpGet("api/culture/cultures"), SignumAllowAnonymous]
public List<CultureInfoEntity> 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<CultureInfoEntity> culture)
{
var ci = ExecutionMode.Global().Using(_ => culture.Retrieve().ToCultureInfo());
Expand Down

0 comments on commit aae765a

Please sign in to comment.