1. install clean with sample data
2. will get NullReferenceException
3. redo install with same database(do not delete database)
4. will get second NullReferenceException
5. redo install the third time with same database(do not delete database)
6. installation success this time, but AdminRole does not have these 2 permissions because of the error:
-"Public store. Access MiniProfiler results"
-"Admin area. Manage Multi-factor Authentication Methods"
error in these 2 blocks since InstallationService.cs haven't run yet to insert the adminRole:
// new permission
if (!_dataProvider.GetTable<PermissionRecord>().Any(pr => string.Compare(pr.SystemName, "AccessProfiling", true) == 0))
{
var profilingPermission = _dataProvider.InsertEntity(
new PermissionRecord
{
Name = "Public store. Access MiniProfiler results",
SystemName = "AccessProfiling",
Category = "PublicStore"
}
);
//add it to the Admin role by default
var adminRole = _dataProvider
.GetTable<CustomerRole>()
.FirstOrDefault(x => x.IsSystemRole && x.SystemName == NopCustomerDefaults.AdministratorsRoleName);
_dataProvider.InsertEntity(
new PermissionRecordCustomerRoleMapping
{
CustomerRoleId = adminRole.Id,
PermissionRecordId = profilingPermission.Id
}
);
}
//<MFA #475>
if (!_dataProvider.GetTable<PermissionRecord>().Any(pr => string.Compare(pr.SystemName, "ManageMultifactorAuthenticationMethods", true) == 0))
{
var multiFactorAuthenticationPermission = _dataProvider.InsertEntity(
new PermissionRecord
{
Name = "Admin area. Manage Multi-factor Authentication Methods",
SystemName = "ManageMultifactorAuthenticationMethods",
Category = "Configuration"
}
);
//add it to the Admin role by default
var adminRole = _dataProvider
.GetTable<CustomerRole>()
.FirstOrDefault(x => x.IsSystemRole && x.SystemName == NopCustomerDefaults.AdministratorsRoleName);
_dataProvider.InsertEntity(
new PermissionRecordCustomerRoleMapping
{
CustomerRoleId = adminRole.Id,
PermissionRecordId = multiFactorAuthenticationPermission.Id
}
);
}