Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: format code with dotnet-format #55

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading