fix bug with privileged users not always showing the most recent profile

temporary bans are now applied to all linked accounts instead of a per-guid basis
rework set level flow
add guid and ip address (if logged in) to public async endpoint
This commit is contained in:
RaidMax
2019-03-24 21:34:20 -05:00
parent 1056c7c335
commit cae6d8389e
15 changed files with 320 additions and 214 deletions

View File

@ -77,7 +77,7 @@ namespace WebfrontCore.Controllers
}
catch (System.Collections.Generic.KeyNotFoundException)
catch (KeyNotFoundException)
{
// force the "banned" client to be signed out
HttpContext.SignOutAsync().Wait(5000);

View File

@ -135,8 +135,8 @@ namespace WebfrontCore.Controllers
public async Task<IActionResult> PrivilegedAsync()
{
var admins = (await Manager.GetClientService().GetPrivilegedClients())
.GroupBy(a => a.AliasLinkId).Where(_clients => _clients.FirstOrDefault(_client => _client.LastConnection == _clients.Max(c => c.LastConnection)) != null)
.Select(_client => _client.First())
.GroupBy(a => a.AliasLinkId)
.Select(_client => _client.OrderByDescending(_c => _c.LastConnection).First())
.OrderByDescending(_client => _client.Level);
var adminsDict = new Dictionary<EFClient.Permission, IList<ClientInfo>>();

View File

@ -33,30 +33,42 @@ namespace WebfrontCore.Controllers
}));
}
/// <summary>
/// retrieves all permanent bans ordered by ban date
/// if request is authorized, it will include the client's ip address.
/// </summary>
/// <returns></returns>
public async Task<IActionResult> PublicAsync()
{
IList<EFPenalty> penalties;
IList<PenaltyInfo> penalties;
using (var ctx = new DatabaseContext(disableTracking: true))
{
penalties = await ctx.Penalties
// todo: this seems like it's pulling unnecessary info from LINQ to entities.
var iqPenalties = ctx.Penalties
.Where(p => p.Type == SharedLibraryCore.Objects.Penalty.PenaltyType.Ban && p.Active)
.ToListAsync();
.OrderByDescending(_penalty => _penalty.When)
.Select(p => new PenaltyInfo()
{
Id = p.PenaltyId,
OffenderId = p.OffenderId,
Offense = p.Offense,
PunisherId = p.PunisherId,
Type = p.Type.ToString(),
TimePunished = p.When.ToString(),
TimeRemaining = "",
AutomatedOffense = Authorized ? p.AutomatedOffense : "",
NetworkId = (ulong)p.Offender.NetworkId,
IPAddress = Authorized ? p.Offender.IPAddressString : ""
});
#if DEBUG == true
var querySql = iqPenalties.ToSql();
#endif
penalties = await iqPenalties.ToListAsync();
}
var penaltiesDto = penalties.Select(p => new PenaltyInfo()
{
Id = p.PenaltyId,
OffenderId = p.OffenderId,
Offense = p.Offense,
PunisherId = p.PunisherId,
Type = p.Type.ToString(),
TimePunished = p.When.ToString(),
TimeRemaining = "",
AutomatedOffense = p.AutomatedOffense
}).ToList();
return Json(penaltiesDto);
return Json(penalties);
}
}
}