summaryrefslogtreecommitdiff
path: root/Program.cs
diff options
context:
space:
mode:
authorSergey Chebotar <s.chebotar@gmail.com>2023-03-06 07:41:35 +0300
committerSergey Chebotar <s.chebotar@gmail.com>2023-03-06 07:41:35 +0300
commit0c4d13caed53b2702eef41461d0c8a4b25df48f6 (patch)
tree6fb6d2d54cedce1c204fb30b75f4d470fbf7ee83 /Program.cs
parentcdd58a8f518d037658518c233e74beea22d03906 (diff)
Base authorization/authentification
Diffstat (limited to 'Program.cs')
-rw-r--r--Program.cs13
1 files changed, 11 insertions, 2 deletions
diff --git a/Program.cs b/Program.cs
index 61ee7fb..eda78fa 100644
--- a/Program.cs
+++ b/Program.cs
@@ -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