source: iknow-api/Program.cs@ 41e4f9f

Last change on this file since 41e4f9f 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: 865 bytes
RevLine 
[2859225]1using Microsoft.EntityFrameworkCore;
[9a57e89]2using iknow_api.Core.Data;
[5b42c8d]3using FinXaccesApi.Services;
4using FinXaccesApi.Repositories;
[2859225]5
[0b16523]6var builder = WebApplication.CreateBuilder(args);
7
8// Add services to the container.
9builder.Services.AddControllers();
10builder.Services.AddOpenApi();
11
[5b42c8d]12// Register DbContext
[5aa102d]13builder.Services.AddDbContext<AppDbContext>(options =>
14 options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection")));
15
[5b42c8d]16// Register your services
17builder.Services.AddScoped<IAuthService, AuthService>();
18builder.Services.AddScoped<IUserRepository, UserRepository>(); // You'll need to add the UserRepository implementation
[9a57e89]19
[0b16523]20var app = builder.Build();
21
22// Configure the HTTP request pipeline.
23if (app.Environment.IsDevelopment())
24{
25 app.MapOpenApi();
26}
27
28app.UseHttpsRedirection();
29app.UseAuthorization();
30app.MapControllers();
31
32app.Run();
Note: See TracBrowser for help on using the repository browser.