Skip to content

Commit

Permalink
style: format code with dotnet-format
Browse files Browse the repository at this point in the history
This commit fixes the style issues introduced in fda3c0b according to the output
from dotnet-format.

Details: None
  • Loading branch information
deepsource-autofix[bot] authored Feb 1, 2024
1 parent fda3c0b commit 3f92a67
Show file tree
Hide file tree
Showing 23 changed files with 1,150 additions and 1,146 deletions.
54 changes: 27 additions & 27 deletions src/AzureAdB2C/Api/ClaimsGeneratorApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,31 @@ public abstract class ClaimsGeneratorApi(
IUserHydrator userHydrator
) : ApiControllerBase(logger)
{
public virtual IClaimsGenerator ClaimsGenerator => claimsGenerator;
public virtual IUserHydrator UserHydrator => userHydrator;

[HttpPost]
[Route("api/claims/validate")]
public async Task<IActionResult> ValidateAsync(
[FromBody] ApiRequest request,
CancellationToken cancellationToken = default
)
{
var result = await ClaimsGenerator.GenerateClaimsAsync(
request,
cancellationToken
);

return result.StatusCode switch
{
StatusCodes.Status200OK => Ok(result),
StatusCodes.Status400BadRequest => BadRequest(result),
StatusCodes.Status401Unauthorized => Unauthorized(result),
StatusCodes.Status403Forbidden => Forbid((result as ApiBlockResponse)!.UserMessage),
StatusCodes.Status404NotFound => NotFound(result),
StatusCodes.Status409Conflict => Conflict(result),
StatusCodes.Status500InternalServerError => Problem((result as ApiErrorResponse)!.DeveloperMessage, statusCode: result.StatusCode),
_ => StatusCode(result.StatusCode ?? StatusCodes.Status200OK, result),
};
}
public virtual IClaimsGenerator ClaimsGenerator => claimsGenerator;
public virtual IUserHydrator UserHydrator => userHydrator;

[HttpPost]
[Route("api/claims/validate")]
public async Task<IActionResult> ValidateAsync(
[FromBody] ApiRequest request,
CancellationToken cancellationToken = default
)
{
var result = await ClaimsGenerator.GenerateClaimsAsync(
request,
cancellationToken
);

return result.StatusCode switch
{
StatusCodes.Status200OK => Ok(result),
StatusCodes.Status400BadRequest => BadRequest(result),
StatusCodes.Status401Unauthorized => Unauthorized(result),
StatusCodes.Status403Forbidden => Forbid((result as ApiBlockResponse)!.UserMessage),
StatusCodes.Status404NotFound => NotFound(result),
StatusCodes.Status409Conflict => Conflict(result),
StatusCodes.Status500InternalServerError => Problem((result as ApiErrorResponse)!.DeveloperMessage, statusCode: result.StatusCode),
_ => StatusCode(result.StatusCode ?? StatusCodes.Status200OK, result),
};
}
}
44 changes: 22 additions & 22 deletions src/AzureAdB2C/Api/ClaimsValidatorApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@ public abstract class ClaimsValidatorApi(
IClaimsValidator claimsValidator
) : ApiControllerBase(logger)
{
public virtual IClaimsValidator ClaimsValidator => claimsValidator;

[HttpPost]
[Route("api/claims/generate")]
public async Task<IActionResult> GenerateAsync(
[FromBody] ApiRequest request,
CancellationToken cancellationToken = default
)
{
var result = await ClaimsValidator.ValidateAsync(request, cancellationToken);

if(IsNullOrWhiteSpace(result.ErrorMessage))
{
var response = new ApiContinueResponse { Version = ClaimsValidator.Version };
return Ok(response);
}
else
{
var response = new ApiValidationErrorResponse(result.ErrorMessage) { Version = ClaimsValidator.Version };
return BadRequest(response);
}
}
public virtual IClaimsValidator ClaimsValidator => claimsValidator;

[HttpPost]
[Route("api/claims/generate")]
public async Task<IActionResult> GenerateAsync(
[FromBody] ApiRequest request,
CancellationToken cancellationToken = default
)
{
var result = await ClaimsValidator.ValidateAsync(request, cancellationToken);

if (IsNullOrWhiteSpace(result.ErrorMessage))
{
var response = new ApiContinueResponse { Version = ClaimsValidator.Version };
return Ok(response);
}
else
{
var response = new ApiValidationErrorResponse(result.ErrorMessage) { Version = ClaimsValidator.Version };
return BadRequest(response);
}
}
}
10 changes: 5 additions & 5 deletions src/AzureAdB2C/Services/ClaimsGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Task<ApiResponse> GenerateClaimsAsync(

public abstract class ClaimsGenerator(IOptions<Version> version) : IClaimsGenerator
{
public virtual Version Version => version.Value;
public abstract Task<ApiResponse> GenerateClaimsAsync(
ApiRequest request,
CancellationToken cancellationToken = default
);
public virtual Version Version => version.Value;
public abstract Task<ApiResponse> GenerateClaimsAsync(
ApiRequest request,
CancellationToken cancellationToken = default
);
}
10 changes: 5 additions & 5 deletions src/AzureAdB2C/Services/ClaimsValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public virtual ValidationResult Validate(ApiRequest request)

public abstract class ClaimsValidator(IOptions<ClaimsValidatorOptions> options) : IClaimsValidator
{
public Version Version => options.Value.Version;
public abstract Task<ValidationResult> ValidateAsync(
ApiRequest request,
CancellationToken cancellationToken = default
);
public Version Version => options.Value.Version;
public abstract Task<ValidationResult> ValidateAsync(
ApiRequest request,
CancellationToken cancellationToken = default
);
}
Loading

0 comments on commit 3f92a67

Please sign in to comment.