Files
jsmr/JSMR.Api/Startup/DevSeeding.cs
Brian Bicknell 9f30ef446a
Some checks failed
ci / build-test (push) Has been cancelled
ci / publish-image (push) Has been cancelled
Added authenication/authorization. Refactored api startup.
2026-02-16 00:20:02 -05:00

30 lines
867 B
C#

using JSMR.Domain.Entities;
using JSMR.Infrastructure.Data;
using Microsoft.EntityFrameworkCore;
namespace JSMR.Api.Startup;
public static class DevSeeding
{
public static async Task SeedDevelopmentAsync(this WebApplication app)
{
using var scope = app.Services.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
var username = "brister";
if (!await db.Users.AnyAsync(u => u.Username == username))
{
db.Users.Add(new User
{
Username = username,
PasswordHash = BCrypt.Net.BCrypt.HashPassword("password"),
Role = "Admin",
IsActive = true
});
await db.SaveChangesAsync();
Console.WriteLine("✅ Seeded development user: brister / password");
}
}
}