From da47d7fdf39904f7d14d486782e3d1538f7268d2 Mon Sep 17 00:00:00 2001 From: kittyegg Date: Wed, 17 Jun 2026 02:59:06 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BE=D0=BF=D1=80=D0=B5=D0=B4=D0=B5=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82?= =?UTF-8?q?=D0=B5=D0=BB=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- URL-Shortener/Controllers/ShortUrlController.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/URL-Shortener/Controllers/ShortUrlController.cs b/URL-Shortener/Controllers/ShortUrlController.cs index bcc62a6..a688c67 100644 --- a/URL-Shortener/Controllers/ShortUrlController.cs +++ b/URL-Shortener/Controllers/ShortUrlController.cs @@ -4,6 +4,7 @@ using URL_Shortener.DTO; using URL_Shortener.Models; using HashidsNet; using Microsoft.AspNetCore.Authorization; +using System.Security.Claims; namespace URL_Shortener.Controllers { @@ -86,7 +87,9 @@ namespace URL_Shortener.Controllers if (shortUrl == null) return NotFound(); - // TODO: определение пользователя по jwt + if (!int.TryParse(User.FindFirstValue(ClaimTypes.NameIdentifier), out var userId) || + shortUrl.UserId != userId) + throw new Exception("Not authorized"); _db.ShortUrls.Remove(shortUrl);