mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
Add strong naming and fix DB path on IIS Express
This commit is contained in:
5
samples/angular/MusicStore/.gitignore
vendored
5
samples/angular/MusicStore/.gitignore
vendored
@@ -3,3 +3,8 @@
|
||||
/wwwroot/ng-app/**/*.js
|
||||
/project.lock.json
|
||||
/music-db.sqlite
|
||||
/Properties/launchSettings.json
|
||||
|
||||
# Obviously you don't really want your DB to go in wwwroot, but due to https://github.com/aspnet/Microsoft.Data.Sqlite/issues/188
|
||||
# it currently does when run from IIS Express. Will resolve this once RC2 is out, which is supposed to eliminate the inconsistency.
|
||||
/wwwroot/music-db.sqlite
|
||||
|
||||
@@ -22,36 +22,10 @@ namespace MusicStore.Models
|
||||
if (await db.Database.EnsureCreatedAsync())
|
||||
{
|
||||
await InsertTestData(serviceProvider);
|
||||
await CreateAdminUser(serviceProvider);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task CreateAdminUser(IServiceProvider serviceProvider)
|
||||
{
|
||||
return;
|
||||
|
||||
var settings = serviceProvider.GetService<IOptions<SiteSettings>>().Value;
|
||||
const string adminRole = "Administrator";
|
||||
|
||||
var userManager = serviceProvider.GetService<UserManager<ApplicationUser>>();
|
||||
var roleManager = serviceProvider.GetService<RoleManager<IdentityRole>>();
|
||||
|
||||
if (!await roleManager.RoleExistsAsync(adminRole))
|
||||
{
|
||||
await roleManager.CreateAsync(new IdentityRole(adminRole));
|
||||
}
|
||||
|
||||
var user = await userManager.FindByNameAsync(settings.DefaultAdminUsername);
|
||||
if (user == null)
|
||||
{
|
||||
user = new ApplicationUser { UserName = settings.DefaultAdminUsername };
|
||||
await userManager.CreateAsync(user, settings.DefaultAdminPassword);
|
||||
await userManager.AddToRoleAsync(user, adminRole);
|
||||
await userManager.AddClaimAsync(user, new Claim("app-ManageStore", "Allowed"));
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task InsertTestData(IServiceProvider serviceProvider)
|
||||
{
|
||||
var albums = GetAlbums(imgUrl, Genres, Artists);
|
||||
|
||||
Reference in New Issue
Block a user