Skip to content

Commit

Permalink
Seed new admin user
Browse files Browse the repository at this point in the history
In an earlier commit the user was not created in the API side which resulted the user to be seeded as a registered user.
  • Loading branch information
Niray Mak committed Apr 15, 2021
1 parent e4bf00d commit e3b8d11
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
10 changes: 10 additions & 0 deletions API/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,16 @@ private static void UpdateDatabase(IApplicationBuilder app, IWebHostEnvironment
// TODO seed embedded projects
}

if(context.User.FirstOrDefault(e => e.IdentityId == "74489498") != null)
{
context.User.Remove(context.User.FirstOrDefault(e => e.IdentityId == "74489498"));
context.SaveChanges();
}

context.User.Add(Seed.SeedAdminUser2(roles));
context.SaveChanges();


// Seed call to action options
List<CallToActionOption> options = Seed.SeedCallToActionOptions();
foreach(CallToActionOption callToActionOption in options)
Expand Down
14 changes: 14 additions & 0 deletions Data/Helpers/Seed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,20 @@ public static List<DataSource> SeedDataSources()
};
}

public static User SeedAdminUser2(List<Role> roles)
{
Role adminRole = roles.Find(i => i.Name == nameof(Defaults.Roles.Administrator));

User user = new User
{
Role = adminRole,
IdentityId = "74489498",
Email = "DeXAdmin@email.com",
Name = "DeX Admin",
};

return user;
}
}

}

0 comments on commit e3b8d11

Please sign in to comment.