Changeset fc7b4b4 for iknow-api/Services


Ignore:
Timestamp:
10/22/25 22:40:03 (11 months ago)
Author:
stefansaveski <stefansaveski19@…>
Branches:
master
Children:
301af3f
Parents:
aed1148
Message:

Implement JWT Authentication and Update User Schema

Replaced repository interface with FinXaccesApi.Repositories in UsersControllers.cs. Updated database schema to use PasswordHash instead of Password. Added new migration files reflecting these changes. Updated service registration in Program.cs to include IAuthService and IUserRepository. Refactored UserRepository.cs and IUserRepository.cs with new methods and namespace changes. Commented out UserService.cs. Updated appsettings with new connection strings and JWT settings. Added BCrypt.Net-Next and System.IdentityModel.Tokens.Jwt packages. Introduced AuthController, UserDTO, AuthService, and IAuthService for handling authentication and user management.

Location:
iknow-api/Services
Files:
2 added
1 edited

Legend:

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

    raed1148 rfc7b4b4  
    1 using Microsoft.EntityFrameworkCore;
    2 using iknow_api.Core.Models;
    3 using iknow_api.Repository.Interfaces;
    4 // ...existing code...
     1//using Microsoft.EntityFrameworkCore;
     2//using iknow_api.Core.Models;
     3//using iknow_api.Repository.Interfaces;
     4//// ...existing code...
    55
    6 namespace iknow_api.Core.Services
    7 {
    8     public class UserService
    9     {
    10         private readonly IUserRepository _users;
     6//namespace iknow_api.Core.Services
     7//{
     8//    public class UserService
     9//    {
     10//        private readonly IUserRepository _users;
    1111
    12         public UserService(IUserRepository users)
    13         {
    14             _users = users;
    15         }
     12//        public UserService(IUserRepository users)
     13//        {
     14//            _users = users;
     15//        }
    1616
    17         public async Task<User> AddUserAsync(User user, CancellationToken cancellationToken = default)
    18         {
    19             if (user == null) throw new ArgumentNullException(nameof(user));
     17//        public async Task<User> AddUserAsync(User user, CancellationToken cancellationToken = default)
     18//        {
     19//            if (user == null) throw new ArgumentNullException(nameof(user));
    2020
    21             if (!string.IsNullOrWhiteSpace(user.Email))
    22             {
    23                 user.Email = user.Email.Trim();
     21//            if (!string.IsNullOrWhiteSpace(user.Email))
     22//            {
     23//                user.Email = user.Email.Trim();
    2424
    25                 var exists = await _users.EmailExistsAsync(user.Email, cancellationToken);
    26                 if (exists)
    27                     throw new InvalidOperationException("A user with this email already exists.");
    28             }
     25//                var exists = await _users.EmailExistsAsync(user.Email, cancellationToken);
     26//                if (exists)
     27//                    throw new InvalidOperationException("A user with this email already exists.");
     28//            }
    2929
    30             return await _users.AddUserAsync(user, cancellationToken);
    31         }
    32     }
    33 }
     30//            return await _users.AddUserAsync(user, cancellationToken);
     31//        }
     32//    }
     33//}
Note: See TracChangeset for help on using the changeset viewer.