From e55c54e75d0cfdc6100015bd5e7a4c2c93040578 Mon Sep 17 00:00:00 2001 From: kittyegg Date: Tue, 16 Jun 2026 00:25:21 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D0=B3=D0=B8=D1=81=D1=82=D1=80?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D1=8F=20=D1=82=D0=B5=D0=BF=D0=B5=D1=80=D1=8C?= =?UTF-8?q?=20=D1=82=D0=BE=D0=B6=D0=B5=20=D0=B2=D0=BE=D0=B7=D0=B2=D1=80?= =?UTF-8?q?=D0=B0=D1=89=D0=B0=D0=B5=D1=82=20jwt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- URL-Shortener/Controllers/UserController.cs | 4 ++-- URL-Shortener/Services/UserService.cs | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/URL-Shortener/Controllers/UserController.cs b/URL-Shortener/Controllers/UserController.cs index 30206bb..3062254 100644 --- a/URL-Shortener/Controllers/UserController.cs +++ b/URL-Shortener/Controllers/UserController.cs @@ -13,8 +13,8 @@ namespace URL_Shortener.Controllers [HttpPost("register")] public async Task RegisterAsync(RegisterUserDTO dto) { - await _userService.RegisterAsync(dto.Name, dto.Email, dto.Password); - return Ok(); + var jwt = await _userService.RegisterAsync(dto.Name, dto.Email, dto.Password); + return Ok(jwt); } [HttpPost("login")] diff --git a/URL-Shortener/Services/UserService.cs b/URL-Shortener/Services/UserService.cs index 9db36d0..0e47540 100644 --- a/URL-Shortener/Services/UserService.cs +++ b/URL-Shortener/Services/UserService.cs @@ -9,7 +9,7 @@ namespace URL_Shortener.Services private readonly AppDbContext _db = db; private readonly JwtService _jwtService = jwtService; - public async Task RegisterAsync(string userName, string email, string password, CancellationToken cancellationToken = default) + public async Task RegisterAsync(string userName, string email, string password, CancellationToken cancellationToken = default) { if (await _db.Users.FirstOrDefaultAsync(u => u.Email == email, cancellationToken) != null) throw new Exception("This user already exists."); @@ -23,6 +23,8 @@ namespace URL_Shortener.Services await _db.Users.AddAsync(user, cancellationToken); await _db.SaveChangesAsync(cancellationToken); + + return _jwtService.GenerateToken(user); } public async Task LoginAsync(string email, string password, CancellationToken cancellationToken = default)