Add AuthController and configure authentication/identity services
This commit is contained in:
@@ -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>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user