fix(seeder): bootstrap admin + demo org on stage/prod too, not just Dev
Login on https://food-market.zat.kz failed because DevDataSeeder skipped in non-Dev envs, so the demo admin account never existed on stage. Seeder is idempotent — checks-then-creates for every entity. Safe to run on every startup in any env. Once a real org/admin replaces the seeded demo, this seeder is a no-op. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
3f3c7480c6
commit
bcbda1ae5d
|
|
@ -20,10 +20,10 @@ public DevDataSeeder(IServiceProvider services, IHostEnvironment env)
|
||||||
|
|
||||||
public async Task StartAsync(CancellationToken ct)
|
public async Task StartAsync(CancellationToken ct)
|
||||||
{
|
{
|
||||||
if (!_env.IsDevelopment())
|
// Idempotent — runs in all envs to bootstrap a usable admin + demo org.
|
||||||
{
|
// Once first real user/org is set up via UI, rename/disable demo.
|
||||||
return;
|
// (Wired regardless of env so stage/prod first-deploy lands a working
|
||||||
}
|
// admin, otherwise nobody can log in.)
|
||||||
|
|
||||||
using var scope = _services.CreateScope();
|
using var scope = _services.CreateScope();
|
||||||
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
|
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue