diff options
author | Sergey Chebotar <s.chebotar@gmail.com> | 2023-03-06 07:41:35 +0300 |
---|---|---|
committer | Sergey Chebotar <s.chebotar@gmail.com> | 2023-03-06 07:41:35 +0300 |
commit | 0c4d13caed53b2702eef41461d0c8a4b25df48f6 (patch) | |
tree | 6fb6d2d54cedce1c204fb30b75f4d470fbf7ee83 /Program.cs | |
parent | cdd58a8f518d037658518c233e74beea22d03906 (diff) |
Base authorization/authentification
Diffstat (limited to 'Program.cs')
-rw-r--r-- | Program.cs | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -1,5 +1,6 @@ using Microsoft.EntityFrameworkCore; using MyDarling.Models; +using Microsoft.AspNetCore.Identity; var builder = WebApplication.CreateBuilder(args); @@ -9,6 +10,14 @@ builder.Services.AddDbContext<DataContext>(opts => opts.EnableSensitiveDataLogging(true); }); +builder.Services.AddDbContext<IdentityContext>(opts => +{ + opts.UseSqlite(builder.Configuration["ConnectionStrings:IdentityDb"]); +}); + +builder.Services.AddIdentity<IdentityUser, IdentityRole>() + .AddEntityFrameworkStores<IdentityContext>(); + builder.Services.AddControllersWithViews(); var app = builder.Build(); @@ -17,7 +26,7 @@ app.UseStaticFiles(); app.MapControllers(); app.MapDefaultControllerRoute(); -// var context = app.Services.CreateScope().ServiceProvider.GetRequiredService<DataContext>(); -// SeedData.SeedDatabase(context); +app.UseAuthentication(); +app.UseAuthorization(); app.Run();
\ No newline at end of file |