Fix up User repository
This commit is contained in:
@@ -377,14 +377,30 @@ SELECT 4 AS [Key], COUNT(id) AS [Value] FROM umbracoUser WHERE userDisabled = 0
|
||||
var groupIds = user2Groups.Select(x => x.UserGroupId).ToList();
|
||||
|
||||
// get groups
|
||||
// We wrap this in a try-catch, as this might throw errors when you try to login before having migrated your database
|
||||
Dictionary<int, UserGroupDto> groups;
|
||||
try
|
||||
{
|
||||
sql = SqlContext.Sql()
|
||||
.Select<UserGroupDto>()
|
||||
.From<UserGroupDto>()
|
||||
.WhereIn<UserGroupDto>(x => x.Id, groupIds);
|
||||
|
||||
sql = SqlContext.Sql()
|
||||
.Select<UserGroupDto>()
|
||||
.From<UserGroupDto>()
|
||||
.WhereIn<UserGroupDto>(x => x.Id, groupIds);
|
||||
groups = Database.Fetch<UserGroupDto>(sql)
|
||||
.ToDictionary(x => x.Id, x => x);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Logger.LogDebug(e, "Couldn't get user groups. This should only happens doing the migration that add new columns to user groups");
|
||||
|
||||
var groups = Database.Fetch<UserGroupDto>(sql)
|
||||
.ToDictionary(x => x.Id, x => x);
|
||||
sql = SqlContext.Sql()
|
||||
.Select<UserGroupDto>(x=>x.Id, x=>x.Alias, x=>x.StartContentId, x=>x.StartMediaId)
|
||||
.From<UserGroupDto>()
|
||||
.WhereIn<UserGroupDto>(x => x.Id, groupIds);
|
||||
|
||||
groups = Database.Fetch<UserGroupDto>(sql)
|
||||
.ToDictionary(x => x.Id, x => x);
|
||||
}
|
||||
|
||||
// get groups2apps
|
||||
|
||||
|
||||
Reference in New Issue
Block a user