blob: 361be3e6b45f3073d8afd8adedb0550d90210bd4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
using Microsoft.EntityFrameworkCore;
using MyDarling.Models;
using Microsoft.AspNetCore.Identity;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddDbContext<DataContext>(opts =>
{
opts.UseSqlite(builder.Configuration["ConnectionStrings:MyDarlingDb"]);
opts.EnableSensitiveDataLogging(true);
});
builder.Services.AddDbContext<IdentityContext>(opts =>
{
opts.UseSqlite(builder.Configuration["ConnectionStrings:IdentityDb"]);
});
builder.Services.AddIdentity<IdentityUser, IdentityRole>()
.AddEntityFrameworkStores<IdentityContext>();
builder.Services.Configure<IdentityOptions>( opts =>
{
opts.Password.RequiredLength = 6;
opts.Password.RequireNonAlphanumeric = false;
opts.User.AllowedUserNameCharacters = "abcdefghijklmnopqrstuvwxyz";
});
builder.Services.AddControllersWithViews();
builder.Services.AddRazorPages();
var app = builder.Build();
app.UseStaticFiles();
app.MapControllers();
app.MapDefaultControllerRoute();
app.MapRazorPages();
app.UseAuthentication();
app.UseAuthorization();
IdentitySeedData.CreateAdminAccount(app.Services, app.Configuration);
app.Run();
|