From 86f66727f37b763c42f0655acea39f09025bf829 Mon Sep 17 00:00:00 2001 From: Veljko Tosic Date: Thu, 12 Feb 2026 19:53:58 +0100 Subject: [PATCH] Removed possibly invalid endpoints, will be refactored to use auth and user context when needed again --- .../AipsWebApi/Controllers/ShapeController.cs | 21 ---------- .../AipsWebApi/Controllers/UserController.cs | 28 ++++++------- .../Controllers/WhiteboardController.cs | 39 +------------------ 3 files changed, 17 insertions(+), 71 deletions(-) diff --git a/dotnet/AipsWebApi/Controllers/ShapeController.cs b/dotnet/AipsWebApi/Controllers/ShapeController.cs index 47e47d9..4da93cc 100644 --- a/dotnet/AipsWebApi/Controllers/ShapeController.cs +++ b/dotnet/AipsWebApi/Controllers/ShapeController.cs @@ -16,25 +16,4 @@ public class ShapeController : ControllerBase { _dispatcher = dispatcher; } - - [HttpPost("arrow")] - public async Task CreateArrow(CreateArrowCommand command, CancellationToken cancellationToken) - { - var result = await _dispatcher.Execute(command, cancellationToken); - return Ok(result); - } - - [HttpPost("textShape")] - public async Task CreateTextShape(CreateTextShapeCommand command, CancellationToken cancellationToken) - { - var result = await _dispatcher.Execute(command, cancellationToken); - return Ok(result); - } - - [HttpPost("line")] - public async Task CreateLine(CreateLineCommand command, CancellationToken cancellationToken) - { - var result = await _dispatcher.Execute(command, cancellationToken); - return Ok(result); - } } \ No newline at end of file diff --git a/dotnet/AipsWebApi/Controllers/UserController.cs b/dotnet/AipsWebApi/Controllers/UserController.cs index fe49a91..1987388 100644 --- a/dotnet/AipsWebApi/Controllers/UserController.cs +++ b/dotnet/AipsWebApi/Controllers/UserController.cs @@ -1,8 +1,9 @@ using AipsCore.Application.Abstract; -using AipsCore.Application.Models.User.Command.CreateUser; +using AipsCore.Application.Authentication; +using AipsCore.Application.Models.User.Command.LogIn; +using AipsCore.Application.Models.User.Command.SignUp; using AipsCore.Application.Models.User.Query.GetUser; -using AipsCore.Domain.Common.Validation; -using AipsCore.Domain.Models.User.ValueObjects; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace AipsWebApi.Controllers; @@ -18,18 +19,19 @@ public class UserController : ControllerBase _dispatcher = dispatcher; } - [HttpGet("{userId}")] - public async Task GetUser([FromRoute] string userId, CancellationToken cancellationToken) + [AllowAnonymous] + [HttpPost("signup")] + public async Task SignUp(SignUpUserCommand command, CancellationToken cancellationToken) { - var query = new GetUserQuery(userId); - var result = await _dispatcher.Execute(query, cancellationToken); - return Ok(result); + var result = await _dispatcher.Execute(command, cancellationToken); + return Ok(result.IdValue); } - - [HttpPost] - public async Task> CreateUser(CreateUserCommand command, CancellationToken cancellationToken) + + [AllowAnonymous] + [HttpPost("login")] + public async Task> LogIn(LogInUserCommand command, CancellationToken cancellationToken) { - var userId = await _dispatcher.Execute(command, cancellationToken); - return Ok(userId.IdValue); + var result = await _dispatcher.Execute(command, cancellationToken); + return Ok(result.Value); } } \ No newline at end of file diff --git a/dotnet/AipsWebApi/Controllers/WhiteboardController.cs b/dotnet/AipsWebApi/Controllers/WhiteboardController.cs index 3be4f40..af8cd08 100644 --- a/dotnet/AipsWebApi/Controllers/WhiteboardController.cs +++ b/dotnet/AipsWebApi/Controllers/WhiteboardController.cs @@ -6,6 +6,7 @@ using AipsCore.Application.Models.Whiteboard.Command.KickUserFromWhiteboard; using AipsCore.Application.Models.Whiteboard.Command.UnbanUserFromWhiteboard; using AipsCore.Application.Models.Whiteboard.Query.GetRecentWhiteboards; using AipsCore.Domain.Models.Whiteboard; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace AipsWebApi.Controllers; @@ -21,47 +22,11 @@ public class WhiteboardController : ControllerBase _dispatcher = dispatcher; } + [Authorize] [HttpPost] public async Task> CreateWhiteboard(CreateWhiteboardCommand command, CancellationToken cancellationToken) { var whiteboardId = await _dispatcher.Execute(command, cancellationToken); return Ok(whiteboardId.IdValue); } - - [HttpPost("adduser")] - public async Task AddUser(AddUserToWhiteboardCommand command, - CancellationToken cancellationToken) - { - await _dispatcher.Execute(command, cancellationToken); - return Ok(); - } - - [HttpGet("recent")] - public async Task>> Recent(GetRecentWhiteboardsQuery query, CancellationToken cancellationToken) - { - var result = await _dispatcher.Execute(query, cancellationToken); - - return Ok(result); - } - - [HttpPut("banUser")] - public async Task BanUserFromWhiteboard(BanUserFromWhiteboardCommand command, CancellationToken cancellationToken) - { - await _dispatcher.Execute(command, cancellationToken); - return Ok(); - } - - [HttpPut("unbanUser")] - public async Task UnbanUserFromWhiteboard(UnbanUserFromWhiteboardCommand command, CancellationToken cancellationToken) - { - await _dispatcher.Execute(command, cancellationToken); - return Ok(); - } - - [HttpPut("kickUser")] - public async Task KickUserFromWhiteboard(KickUserFromWhiteboardCommand command, CancellationToken cancellationToken) - { - await _dispatcher.Execute(command, cancellationToken); - return Ok(); - } } \ No newline at end of file