aboutsummaryrefslogtreecommitdiff
path: root/Backend/Api/Api/Controllers/UserController.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Backend/Api/Api/Controllers/UserController.cs')
-rw-r--r--Backend/Api/Api/Controllers/UserController.cs41
1 files changed, 41 insertions, 0 deletions
diff --git a/Backend/Api/Api/Controllers/UserController.cs b/Backend/Api/Api/Controllers/UserController.cs
index 4d7905a..4937467 100644
--- a/Backend/Api/Api/Controllers/UserController.cs
+++ b/Backend/Api/Api/Controllers/UserController.cs
@@ -123,5 +123,46 @@ namespace Api.Controllers
{
return Ok(await _userService.GetMyFollowers());
}
+
+ [HttpGet("profile/stats")]
+ [Authorize(Roles = "User")]
+ public async Task<ActionResult<UserStats>> SelfStats()
+ {
+ var id = await _userService.UserIdFromJwt();
+ var tosend = await _postService.UserStats(id);
+ if (tosend != null)
+ return Ok(tosend);
+ return BadRequest();
+ }
+ [HttpGet("{username}/profile/stats")]
+ [Authorize(Roles = "User")]
+ public async Task<ActionResult<UserStats>> GetStats(string username)
+ {
+ var rez = await _userService.GetUserData(username);
+ if (rez == null)
+ return BadRequest();
+ var tosend = await _postService.UserStats(rez._id);
+ if (tosend != null)
+ return Ok(tosend);
+ return BadRequest();
+ }
+
+ [HttpGet("{newUsername}/profile/changeMyUsername")]
+ [Authorize(Roles = "User")]
+ public async Task<ActionResult<int>> ChangeMyProfileUsername(string newUsername)
+ {
+ return await _userService.ChangeMyProfileUsername(newUsername);
+ }
+
+
+ [HttpGet("{id}/changeMyName")]
+ [Authorize(Roles = "User")]
+ public async Task<ActionResult<bool>> ChangeMyProfileName(string newName)
+ {
+ return Ok(await _userService.ChangeMyProfileName(newName));
+ }
+
+
+
}
}