From e30110bcff0d6f4db86b2fada9bba13ac796c476 Mon Sep 17 00:00:00 2001 From: Jeas0001 Date: Wed, 7 May 2025 12:30:12 +0200 Subject: [PATCH] Usercontrollers comments --- backend/API/Controllers/UserController.cs | 33 +++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/backend/API/Controllers/UserController.cs b/backend/API/Controllers/UserController.cs index 8bb69eb..28e7ebe 100644 --- a/backend/API/Controllers/UserController.cs +++ b/backend/API/Controllers/UserController.cs @@ -17,6 +17,10 @@ namespace API.Controllers _userLogic = userLogic; } + /// + /// Gets the users email and username + /// + /// returns the users email, username and Id [Authorize] [HttpGet("get")] public async Task ReadUser() @@ -27,18 +31,33 @@ namespace API.Controllers return await _userLogic.GetUser(userId); } + /// + /// Logins a user + /// + /// The users login credentials + /// Returns a jwttoken their username, id and a refreshtoken [HttpPost("login")] public async Task Login([FromBody] LoginDTO loginDTO) { return await _userLogic.Login(loginDTO); } + /// + /// Create a new user + /// + /// contains the username email and password + /// returns a okobjectresult with a boolean that is true if it fails it returns a confliftobjectresult with a message of why it failed [HttpPost("create")] public async Task CreateUser([FromBody] CreateUserDTO userDTO) { return await _userLogic.RegisterUser(userDTO); } + /// + /// Changes the password of the user + /// + /// Contains the old password and the new one + /// returns a okobjectresult with a boolean that is true if it fails it returns a confliftobjectresult with a message of why it failed [Authorize] [HttpPut("change-password")] public async Task ChangePassword([FromBody] ChangePasswordDTO passwordDTO) @@ -49,6 +68,11 @@ namespace API.Controllers return await _userLogic.ChangePassword(passwordDTO, userId); } + /// + /// Edits the email and username of the user + /// + /// The updated username and email + /// returns a okobjectresult with a boolean that is true if it fails it returns a confliftobjectresult with a message of why it failed [Authorize] [HttpPut("update")] public async Task UpdateUser([FromBody] UpdateUserDTO userDTO) @@ -59,6 +83,10 @@ namespace API.Controllers return await _userLogic.EditProfile(userDTO, userId); } + /// + /// Deletes the user + /// + /// returns a okobjectresult with a boolean that is true if it fails it returns a confliftobjectresult with a message of why it failed [Authorize] [HttpDelete("delete")] public async Task DeleteUser() @@ -69,6 +97,11 @@ namespace API.Controllers return await _userLogic.DeleteUser(userId); } + /// + /// For when the jwt token is outdated + /// + /// contains a string with the refreshtoken + /// returns a new refreshtoken and new jwt token [HttpPost("refreshtoken")] public async Task RefreashToken([FromBody] RefreshTokenDTO refreshToken) {