Changeset 5eb7847 for iknow-api/Services


Ignore:
Timestamp:
10/26/25 20:52:35 (11 months ago)
Author:
stefansaveski <stefansaveski19@…>
Branches:
master
Children:
28759eb, 4e061d8, 4f5d8fd
Parents:
8e32210
Message:

Add JWT authentication and refactor namespaces

Introduced JWT-based authentication and authorization:

  • Configured JWT authentication in Program.cs with token validation.
  • Added [Authorize] attribute to a new getstring endpoint.

Refactored namespaces for consistency:

  • Updated namespaces from iknow_api.Core.* to iknow_api.*.

Enhanced middleware and dependency injection:

  • Registered IAuthService and IUserRepository.
  • Added app.UseAuthentication() and app.UseAuthorization().

Removed unused code and dependencies:

  • Deleted WeatherForecast class.
  • Cleaned up redundant imports.

Updated project dependencies to include JWT authentication library.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • iknow-api/Services/Implementations/AuthService.cs

    r8e32210 r5eb7847  
    44using BCrypt.Net;
    55using iknow_api.Controllers;
    6 using iknow_api.Core.Models;
     6using iknow_api.Models;
    77using iknow_api.DTOs;
    88using iknow_api.Repositories;
     
    3636                Bday = DateTime.SpecifyKind(registerDto.Bday, DateTimeKind.Utc),
    3737                CreatedAt = DateTime.UtcNow,
    38                 Role = (Core.Models.UserRole)registerDto.Role
     38                Role = (Models.UserRole)registerDto.Role
    3939            };
    4040
     
    6262            {
    6363                new Claim("id", user.Id.ToString()),
    64                 new Claim("username", user.Email ?? string.Empty),
     64                new Claim("email", user.Email ?? string.Empty),
    6565                new Claim("role", user.Role.ToString())
    6666            };
Note: See TracChangeset for help on using the changeset viewer.