mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-29 08:00:19 +01:00
Allow User.GetId on current user
This commit is contained in:
@@ -172,9 +172,15 @@ namespace Tgstation.Server.Host.Controllers
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[TgsAuthorize(AdministrationRights.EditUsers)]
|
||||
[TgsAuthorize]
|
||||
public override async Task<IActionResult> GetId(long id, CancellationToken cancellationToken)
|
||||
{
|
||||
if (id == AuthenticationContext.User.Id)
|
||||
return await Read(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (!((AdministrationRights)AuthenticationContext.GetRight(RightsType.Administration)).HasFlag(AdministrationRights.EditUsers))
|
||||
return Forbid();
|
||||
|
||||
var user = await DatabaseContext.Users.Where(x => x.Id == id).FirstOrDefaultAsync(cancellationToken).ConfigureAwait(false);
|
||||
if (user == default)
|
||||
return NotFound();
|
||||
|
||||
Reference in New Issue
Block a user