Usercontrollers comments

This commit is contained in:
Jeas0001 2025-05-07 12:30:12 +02:00
parent 38cf388ea8
commit e30110bcff

View File

@ -17,6 +17,10 @@ namespace API.Controllers
_userLogic = userLogic;
}
/// <summary>
/// Gets the users email and username
/// </summary>
/// <returns>returns the users email, username and Id</returns>
[Authorize]
[HttpGet("get")]
public async Task<IActionResult> ReadUser()
@ -27,18 +31,33 @@ namespace API.Controllers
return await _userLogic.GetUser(userId);
}
/// <summary>
/// Logins a user
/// </summary>
/// <param name="loginDTO">The users login credentials</param>
/// <returns>Returns a jwttoken their username, id and a refreshtoken</returns>
[HttpPost("login")]
public async Task<IActionResult> Login([FromBody] LoginDTO loginDTO)
{
return await _userLogic.Login(loginDTO);
}
/// <summary>
/// Create a new user
/// </summary>
/// <param name="userDTO">contains the username email and password</param>
/// <returns>returns a okobjectresult with a boolean that is true if it fails it returns a confliftobjectresult with a message of why it failed</returns>
[HttpPost("create")]
public async Task<IActionResult> CreateUser([FromBody] CreateUserDTO userDTO)
{
return await _userLogic.RegisterUser(userDTO);
}
/// <summary>
/// Changes the password of the user
/// </summary>
/// <param name="passwordDTO">Contains the old password and the new one</param>
/// <returns>returns a okobjectresult with a boolean that is true if it fails it returns a confliftobjectresult with a message of why it failed</returns>
[Authorize]
[HttpPut("change-password")]
public async Task<IActionResult> ChangePassword([FromBody] ChangePasswordDTO passwordDTO)
@ -49,6 +68,11 @@ namespace API.Controllers
return await _userLogic.ChangePassword(passwordDTO, userId);
}
/// <summary>
/// Edits the email and username of the user
/// </summary>
/// <param name="userDTO">The updated username and email</param>
/// <returns>returns a okobjectresult with a boolean that is true if it fails it returns a confliftobjectresult with a message of why it failed</returns>
[Authorize]
[HttpPut("update")]
public async Task<IActionResult> UpdateUser([FromBody] UpdateUserDTO userDTO)
@ -59,6 +83,10 @@ namespace API.Controllers
return await _userLogic.EditProfile(userDTO, userId);
}
/// <summary>
/// Deletes the user
/// </summary>
/// <returns>returns a okobjectresult with a boolean that is true if it fails it returns a confliftobjectresult with a message of why it failed</returns>
[Authorize]
[HttpDelete("delete")]
public async Task<IActionResult> DeleteUser()
@ -69,6 +97,11 @@ namespace API.Controllers
return await _userLogic.DeleteUser(userId);
}
/// <summary>
/// For when the jwt token is outdated
/// </summary>
/// <param name="refreshToken">contains a string with the refreshtoken</param>
/// <returns>returns a new refreshtoken and new jwt token</returns>
[HttpPost("refreshtoken")]
public async Task<IActionResult> RefreashToken([FromBody] RefreshTokenDTO refreshToken)
{