|
Last change
on this file since 5b42c8d was 5b42c8d, checked in by stefansaveski <stefansaveski19@…>, 11 months ago |
|
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.
|
-
Property mode
set to
100644
|
|
File size:
1.0 KB
|
| Line | |
|---|
| 1 | //using Microsoft.EntityFrameworkCore;
|
|---|
| 2 | //using iknow_api.Core.Models;
|
|---|
| 3 | //using iknow_api.Repository.Interfaces;
|
|---|
| 4 | //// ...existing code...
|
|---|
| 5 |
|
|---|
| 6 | //namespace iknow_api.Core.Services
|
|---|
| 7 | //{
|
|---|
| 8 | // public class UserService
|
|---|
| 9 | // {
|
|---|
| 10 | // private readonly IUserRepository _users;
|
|---|
| 11 |
|
|---|
| 12 | // public UserService(IUserRepository users)
|
|---|
| 13 | // {
|
|---|
| 14 | // _users = users;
|
|---|
| 15 | // }
|
|---|
| 16 |
|
|---|
| 17 | // public async Task<User> AddUserAsync(User user, CancellationToken cancellationToken = default)
|
|---|
| 18 | // {
|
|---|
| 19 | // if (user == null) throw new ArgumentNullException(nameof(user));
|
|---|
| 20 |
|
|---|
| 21 | // if (!string.IsNullOrWhiteSpace(user.Email))
|
|---|
| 22 | // {
|
|---|
| 23 | // user.Email = user.Email.Trim();
|
|---|
| 24 |
|
|---|
| 25 | // var exists = await _users.EmailExistsAsync(user.Email, cancellationToken);
|
|---|
| 26 | // if (exists)
|
|---|
| 27 | // throw new InvalidOperationException("A user with this email already exists.");
|
|---|
| 28 | // }
|
|---|
| 29 |
|
|---|
| 30 | // return await _users.AddUserAsync(user, cancellationToken);
|
|---|
| 31 | // }
|
|---|
| 32 | // }
|
|---|
| 33 | //} |
|---|
Note:
See
TracBrowser
for help on using the repository browser.