ree
This commit is contained in:
parent
41c2f00834
commit
81f93c5dd1
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Suspectus.Gandalf.Bridgekeeper.Contracts.Controller.Auth;
|
||||||
|
|
||||||
namespace Suspectus.Gandalf.Bridgekeeper.Api.Controllers;
|
namespace Suspectus.Gandalf.Bridgekeeper.Api.Controllers;
|
||||||
|
|
||||||
@ -12,13 +13,29 @@ public class AuthController : ControllerBase
|
|||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("[action]")]
|
[HttpPost("[action]")]
|
||||||
public async Task<IActionResult> Login()
|
public async Task<IActionResult> Login([FromBody] LoginCommand loginCommand)
|
||||||
{
|
{
|
||||||
return Ok(true);
|
Response.Cookies.Append("MithrandirSession", loginCommand.UsernameOrEmail, new CookieOptions
|
||||||
|
{
|
||||||
|
Secure = true,
|
||||||
|
HttpOnly = true,
|
||||||
|
SameSite = SameSiteMode.Lax,
|
||||||
|
Expires = DateTime.UtcNow.AddMinutes(30)
|
||||||
|
});
|
||||||
|
|
||||||
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("[action]")]
|
[HttpGet("[action]")]
|
||||||
|
public async Task<IActionResult> Logout()
|
||||||
|
{
|
||||||
|
Response.Cookies.Delete("MithrandirSession");
|
||||||
|
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("[action]")]
|
||||||
public async Task<IActionResult> Register()
|
public async Task<IActionResult> Register()
|
||||||
{
|
{
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
|
|||||||
@ -1,23 +1,16 @@
|
|||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
// Add services to the container.
|
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
|
||||||
builder.Services.AddOpenApi();
|
builder.Services.AddOpenApi();
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
|
||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
app.MapOpenApi();
|
app.MapOpenApi();
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
@ -11,4 +11,13 @@
|
|||||||
<PackageReference Include="MediatR" Version="12.4.1" />
|
<PackageReference Include="MediatR" Version="12.4.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Contracts\Auth\Commands\" />
|
||||||
|
<Folder Include="Contracts\Auth\Queries\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Suspectus.Gandalf.Bridgekeeper.Contracts\Suspectus.Gandalf.Bridgekeeper.Contracts.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -0,0 +1,9 @@
|
|||||||
|
using Suspectus.Gandalf.Core.Abstractions.CQRS;
|
||||||
|
|
||||||
|
namespace Suspectus.Gandalf.Bridgekeeper.Contracts.Controller.Auth;
|
||||||
|
|
||||||
|
public class LoginCommand : ICommand<bool>
|
||||||
|
{
|
||||||
|
public required string UsernameOrEmail { get; set; }
|
||||||
|
public required string Password { get; set; }
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Suspectus.Gandalf.Core.Abstractions\Suspectus.Gandalf.Core.Abstractions.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
using LanguageExt.Common;
|
||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace Suspectus.Gandalf.Core.Abstractions.CQRS;
|
||||||
|
|
||||||
|
public interface ICommand<T> : IRequest<Result<T>>;
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="LanguageExt.Core" Version="4.4.9" />
|
||||||
|
<PackageReference Include="MediatR" Version="12.4.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@ -16,6 +16,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Suspectus.Gandalf.Bridgekee
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{3E672AE3-D2E4-49C0-AB18-65E799E5277A}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{3E672AE3-D2E4-49C0-AB18-65E799E5277A}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Suspectus.Gandalf.Core.Abstractions", "Suspectus.Gandalf.Core.Abstractions\Suspectus.Gandalf.Core.Abstractions.csproj", "{F8333692-CA81-4298-A2F5-CF7D3ACCE230}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Suspectus.Gandalf.Bridgekeeper.Contracts", "Suspectus.Gandalf.Bridgekeeper.Contracts\Suspectus.Gandalf.Bridgekeeper.Contracts.csproj", "{4ED2E3BC-FE29-4041-8274-987EB60BD5FF}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -42,6 +46,14 @@ Global
|
|||||||
{264B8A9E-7A70-4DE3-906B-7E0722D09205}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{264B8A9E-7A70-4DE3-906B-7E0722D09205}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{264B8A9E-7A70-4DE3-906B-7E0722D09205}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{264B8A9E-7A70-4DE3-906B-7E0722D09205}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{264B8A9E-7A70-4DE3-906B-7E0722D09205}.Release|Any CPU.Build.0 = Release|Any CPU
|
{264B8A9E-7A70-4DE3-906B-7E0722D09205}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{F8333692-CA81-4298-A2F5-CF7D3ACCE230}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{F8333692-CA81-4298-A2F5-CF7D3ACCE230}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{F8333692-CA81-4298-A2F5-CF7D3ACCE230}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{F8333692-CA81-4298-A2F5-CF7D3ACCE230}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{4ED2E3BC-FE29-4041-8274-987EB60BD5FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{4ED2E3BC-FE29-4041-8274-987EB60BD5FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{4ED2E3BC-FE29-4041-8274-987EB60BD5FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{4ED2E3BC-FE29-4041-8274-987EB60BD5FF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(NestedProjects) = preSolution
|
GlobalSection(NestedProjects) = preSolution
|
||||||
{44C283FD-2E01-496C-9E8F-4E43C26C9733} = {A82EA24B-1379-41B2-A363-CDCBF9F18833}
|
{44C283FD-2E01-496C-9E8F-4E43C26C9733} = {A82EA24B-1379-41B2-A363-CDCBF9F18833}
|
||||||
@ -49,5 +61,7 @@ Global
|
|||||||
{B4AF6985-3268-4C2E-9C50-D92DA7D3711D} = {A82EA24B-1379-41B2-A363-CDCBF9F18833}
|
{B4AF6985-3268-4C2E-9C50-D92DA7D3711D} = {A82EA24B-1379-41B2-A363-CDCBF9F18833}
|
||||||
{C8C3047B-ED0B-4516-A282-8B07E3EEB430} = {A82EA24B-1379-41B2-A363-CDCBF9F18833}
|
{C8C3047B-ED0B-4516-A282-8B07E3EEB430} = {A82EA24B-1379-41B2-A363-CDCBF9F18833}
|
||||||
{264B8A9E-7A70-4DE3-906B-7E0722D09205} = {D54D8A40-A5C3-4273-B4D7-F2B83056161B}
|
{264B8A9E-7A70-4DE3-906B-7E0722D09205} = {D54D8A40-A5C3-4273-B4D7-F2B83056161B}
|
||||||
|
{F8333692-CA81-4298-A2F5-CF7D3ACCE230} = {3E672AE3-D2E4-49C0-AB18-65E799E5277A}
|
||||||
|
{4ED2E3BC-FE29-4041-8274-987EB60BD5FF} = {D54D8A40-A5C3-4273-B4D7-F2B83056161B}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user