Add AuthController and configure authentication/identity services

This commit is contained in:
2026-01-25 15:29:28 +01:00
parent d1a72876d2
commit 91dd8d1603
2 changed files with 21 additions and 3 deletions

View File

@@ -1,7 +1,9 @@
using API.Database;
using API.Models.Internal.User;
using API.Repository.AgeGroup;
using API.Services;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.UI.Services;
using Microsoft.EntityFrameworkCore;
var webRoot = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), "..", "wwwroot"));
@@ -21,9 +23,12 @@ builder.Services.AddAuthorization();
builder.Services.AddAuthentication()
.AddCookie(IdentityConstants.ApplicationScheme);
builder.Services.AddIdentityCore<User>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddApiEndpoints();
builder.Services.AddIdentityCore<User>(options =>
{
options.SignIn.RequireConfirmedAccount = true;
options.User.RequireUniqueEmail = true;
}).AddEntityFrameworkStores<ApplicationDbContext>().AddDefaultTokenProviders();
// Database
var postgresConnection = builder.Configuration.GetConnectionString("PostgresConnection");
@@ -37,6 +42,9 @@ else
builder.Services.AddDbContext<ApplicationDbContext>(options => options.UseSqlite("Data Source=app.db"));
}
// Adding Email Service (Plunk)
builder.Services.AddHttpClient<IEmailSender, PlunkEmailSender>();
// Adding Database Services
builder.Services.AddScoped<IAgeGroupService, AgeGroupService>();