Skip to content

Commit

Permalink
Fix string interpolation in queries.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed Jul 27, 2023
1 parent a0807cf commit d0e6bce
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Server/Services/DataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ public bool AddUserToDeviceGroup(string orgId, string groupId, string userName,
var user = dbContext.Users
.Include(x => x.DeviceGroups)
.FirstOrDefault(x =>
$"{x.UserName}".ToLower() == userName &&
x.UserName!.ToLower() == userName &&
x.OrganizationID == orgId);

if (user == null)
Expand Down Expand Up @@ -997,7 +997,9 @@ public bool DoesUserExist(string userName)
return false;
}

return dbContext.Users.Any(x => $"{x.UserName}".Trim().ToLower() == userName.Trim().ToLower());
return dbContext.Users
.Where(x => x.UserName != null)
.Any(x => x.UserName!.Trim().ToLower() == userName.Trim().ToLower());
}

public bool DoesUserHaveAccessToDevice(string deviceId, RemotelyUser remotelyUser)
Expand Down Expand Up @@ -1417,7 +1419,6 @@ public DeviceGroup[] GetDeviceGroupsForOrganization(string organizationId)
return dbContext.DeviceGroups
.AsNoTracking()
.Include(x => x.Users)
.ThenInclude(x => x.DeviceGroups)
.Where(x => x.OrganizationID == organizationId)
.OrderBy(x => x.Name)
.ToArray();
Expand Down Expand Up @@ -1715,8 +1716,8 @@ public List<string> GetServerAdmins()

return dbContext.Users
.AsNoTracking()
.Where(x => x.IsServerAdmin)
.Select(x => $"{x.UserName}")
.Where(x => x.IsServerAdmin && x.UserName != null)
.Select(x => x.UserName!)
.ToList();
}

Expand Down

0 comments on commit d0e6bce

Please sign in to comment.