This commit is contained in:
2024-01-19 17:25:56 +01:00
Unverified
parent ab9be442ee
commit 5d5a69ccf7
69 changed files with 3769 additions and 0 deletions

View File

@@ -0,0 +1,96 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Identity.Client;
using SecureBank.API.Services;
using SecureBank.Common;
using SecureBank.Common.Accounts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace SecureBank.API.Controllers
{
[ApiController]
[Route("api/accounts")]
public class AccountsController : ControllerBase
{
#region SERVICES
private IAccountsService _accountsService;
#endregion
#region CONSTRUCTORS
public AccountsController(IAccountsService accountsService)
{
_accountsService = accountsService;
}
#endregion
#region METHODS
[HttpPost]
[Route("create-account")]
[AllowAnonymous]
public async Task<ActionResult<APIResponse<int>>> CreateAccount([FromBody] CreateAccountRequest data)
{
APIResponse<int> response = await _accountsService.CreateAccount(data);
if (response.Success)
{
return Ok(response);
}
else
{
return BadRequest(response);
}
}
[HttpGet]
[Route("{account_id}/password-variant")]
[AllowAnonymous]
public async Task<ActionResult<APIResponse<GetPasswordVariantResponse>>> GetPasswordVariant([FromRoute(Name = "account_id")] int accountId)
{
APIResponse<GetPasswordVariantResponse> response = await _accountsService.GetPasswordVariant(accountId);
if (response.Success)
{
return Ok(response);
}
else
{
return BadRequest(response);
}
}
[HttpPost]
[Route("{account_id}/authentication")]
[AllowAnonymous]
/*
* Action codes:
* 1 - Go back to client code input
* 2 - Failed login count increment
*/
public async Task<ActionResult<APIResponse<string>>> Authentication([FromRoute(Name = "account_id")] int accountId, [FromBody] AuthenticationRequest data)
{
APIResponse<string> response = await _accountsService.Authentication(accountId, data);
if (response.Success)
{
return Ok(response);
}
else
{
return BadRequest(response);
}
}
#endregion
}
}

View File

@@ -0,0 +1,10 @@
{
"profiles": {
"SecureBank.API": {
"commandName": "Project"
},
"Docker": {
"commandName": "Docker"
}
}
}

View File

@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.5.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\SecureBank.Common\SecureBank.Common.csproj" />
<ProjectReference Include="..\SecureBank.API.Services\SecureBank.API.Services.csproj" />
</ItemGroup>
</Project>