aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline/Controllers/UserAvatarController.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-11-13 16:20:45 +0800
committerGitHub <noreply@github.com>2020-11-13 16:20:45 +0800
commit299067a798077363d0df281fc3bfb4160df06e1f (patch)
tree9750c3e57d803efaa65a13c9c47886746d77d721 /BackEnd/Timeline/Controllers/UserAvatarController.cs
parent0c789f235f38aa238048b31b9715810d397d3420 (diff)
parent79673878b5427bbedbc4ff4323dce3958d307b49 (diff)
downloadtimeline-299067a798077363d0df281fc3bfb4160df06e1f.tar.gz
timeline-299067a798077363d0df281fc3bfb4160df06e1f.tar.bz2
timeline-299067a798077363d0df281fc3bfb4160df06e1f.zip
Merge pull request #183 from crupest/auth
Refactor auth module to enable more flexiable permission control.
Diffstat (limited to 'BackEnd/Timeline/Controllers/UserAvatarController.cs')
-rw-r--r--BackEnd/Timeline/Controllers/UserAvatarController.cs7
1 files changed, 3 insertions, 4 deletions
diff --git a/BackEnd/Timeline/Controllers/UserAvatarController.cs b/BackEnd/Timeline/Controllers/UserAvatarController.cs
index bc4afa30..f3b7fff8 100644
--- a/BackEnd/Timeline/Controllers/UserAvatarController.cs
+++ b/BackEnd/Timeline/Controllers/UserAvatarController.cs
@@ -5,7 +5,6 @@ using Microsoft.Extensions.Logging;
using Microsoft.Net.Http.Headers;
using System;
using System.Threading.Tasks;
-using Timeline.Auth;
using Timeline.Filters;
using Timeline.Helpers;
using Timeline.Models;
@@ -86,7 +85,7 @@ namespace Timeline.Controllers
[ProducesResponseType(StatusCodes.Status403Forbidden)]
public async Task<IActionResult> Put([FromRoute][Username] string username, [FromBody] ByteData body)
{
- if (!User.IsAdministrator() && User.Identity.Name != username)
+ if (!this.UserHasPermission(UserPermission.UserManagement) && User.Identity!.Name != username)
{
_logger.LogInformation(Log.Format(LogPutForbid,
("Operator Username", User.Identity.Name), ("Username To Put Avatar", username)));
@@ -149,10 +148,10 @@ namespace Timeline.Controllers
[Authorize]
public async Task<IActionResult> Delete([FromRoute][Username] string username)
{
- if (!User.IsAdministrator() && User.Identity.Name != username)
+ if (!this.UserHasPermission(UserPermission.UserManagement) && User.Identity!.Name != username)
{
_logger.LogInformation(Log.Format(LogDeleteForbid,
- ("Operator Username", User.Identity.Name), ("Username To Delete Avatar", username)));
+ ("Operator Username", User.Identity!.Name), ("Username To Delete Avatar", username)));
return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.Forbid());
}