0
0
MyDarling/Program.cs

45 lines
1.2 KiB
C#
Raw Normal View History

2023-01-31 15:55:44 +03:00
using Microsoft.EntityFrameworkCore;
using MyDarling.Models;
2023-06-05 07:01:44 +03:00
using MyDarling.Services;
2023-03-06 07:41:35 +03:00
using Microsoft.AspNetCore.Identity;
2023-01-31 15:55:44 +03:00
2023-06-05 07:01:44 +03:00
2023-01-31 14:54:32 +03:00
var builder = WebApplication.CreateBuilder(args);
2023-01-31 15:55:44 +03:00
2023-02-16 07:23:48 +03:00
builder.Services.AddDbContext<DataContext>(opts =>
2023-01-31 15:55:44 +03:00
{
2023-02-21 07:52:11 +03:00
opts.UseSqlite(builder.Configuration["ConnectionStrings:MyDarlingDb"]);
opts.EnableSensitiveDataLogging(true);
2023-01-31 15:55:44 +03:00
});
2023-02-21 07:52:11 +03:00
2023-03-06 07:41:35 +03:00
builder.Services.AddDbContext<IdentityContext>(opts =>
{
opts.UseSqlite(builder.Configuration["ConnectionStrings:IdentityDb"]);
});
builder.Services.AddIdentity<IdentityUser, IdentityRole>()
.AddEntityFrameworkStores<IdentityContext>();
2023-03-07 08:18:01 +03:00
builder.Services.Configure<IdentityOptions>( opts =>
{
opts.Password.RequiredLength = 6;
opts.Password.RequireNonAlphanumeric = false;
opts.User.AllowedUserNameCharacters = "abcdefghijklmnopqrstuvwxyz";
});
2023-03-06 07:41:35 +03:00
2023-06-05 07:01:44 +03:00
builder.Services.AddTransient<IImageResizer, ImageResizer>();
2023-01-31 14:54:32 +03:00
builder.Services.AddControllersWithViews();
2023-05-30 07:18:47 +03:00
builder.Services.AddRazorPages();
2023-01-31 15:55:44 +03:00
2023-01-31 14:54:32 +03:00
var app = builder.Build();
app.UseStaticFiles();
app.MapControllers();
app.MapDefaultControllerRoute();
2023-05-30 07:18:47 +03:00
app.MapRazorPages();
2023-01-31 14:54:32 +03:00
2023-03-06 07:41:35 +03:00
app.UseAuthentication();
app.UseAuthorization();
2023-03-07 08:18:01 +03:00
IdentitySeedData.CreateAdminAccount(app.Services, app.Configuration);
2023-01-31 15:55:44 +03:00
2023-01-31 14:54:32 +03:00
app.Run();