prevent starting if no servers can be connected to

fix nextmap issue on t6
fix bug with kicking client for profane name
This commit is contained in:
RaidMax
2019-04-16 11:32:42 -05:00
parent b134cd4728
commit 02cad10d77
10 changed files with 65 additions and 20 deletions

View File

@ -140,9 +140,14 @@ namespace WebfrontCore.Controllers
public async Task<IActionResult> Meta(int id, int count, int offset, DateTime? startAt)
{
var meta = await MetaService.GetRuntimeMeta(id, startAt == null ? offset : 0, count, startAt ?? DateTime.UtcNow);
IEnumerable<ProfileMeta> meta = await MetaService.GetRuntimeMeta(id, startAt == null ? offset : 0, count, startAt ?? DateTime.UtcNow);
if (meta.Count == 0)
if (!Authorized)
{
meta = meta.Where(_meta => !_meta.Sensitive);
}
if (meta.Count() == 0)
{
return Ok();
}

View File

@ -12,12 +12,22 @@ namespace WebfrontCore.Controllers
{
public IActionResult Edit()
{
if (Client.Level != SharedLibraryCore.Database.Models.EFClient.Permission.Owner)
{
return Unauthorized();
}
return View("Index", Manager.GetApplicationSettings().Configuration());
}
[HttpPost]
public async Task<IActionResult> Edit(ApplicationConfiguration newConfiguration, bool addNewServer = false, bool shouldSave = false)
{
if (Client.Level != SharedLibraryCore.Database.Models.EFClient.Permission.Owner)
{
return Unauthorized();
}
if (shouldSave)
{
var currentConfiguration = Manager.GetApplicationSettings().Configuration();
@ -48,6 +58,11 @@ namespace WebfrontCore.Controllers
public IActionResult GetNewListItem(string propertyName, int itemCount)
{
if (Client.Level != SharedLibraryCore.Database.Models.EFClient.Permission.Owner)
{
return Unauthorized();
}
var configInfo = new ConfigurationInfo()
{
NewItemCount = itemCount,

View File

@ -1,6 +1,11 @@
using Microsoft.AspNetCore.Mvc;
using SharedLibraryCore.Database.Models;
using SharedLibraryCore.Dtos;
using SharedLibraryCore.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
namespace WebfrontCore.ViewComponents
@ -9,7 +14,15 @@ namespace WebfrontCore.ViewComponents
{
public async Task<IViewComponentResult> InvokeAsync(int clientId, int count, int offset, DateTime? startAt)
{
var meta = await MetaService.GetRuntimeMeta(clientId, offset, count, startAt ?? DateTime.UtcNow);
var level = (EFClient.Permission)Enum.Parse(typeof(EFClient.Permission), UserClaimsPrincipal.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Role)?.Value ?? "User");
IEnumerable<ProfileMeta> meta = await MetaService.GetRuntimeMeta(clientId, offset, count, startAt ?? DateTime.UtcNow);
if (level < EFClient.Permission.Trusted)
{
meta = meta.Where(_meta => !_meta.Sensitive);
}
return View("_List", meta);
}
}

View File

@ -1,4 +1,4 @@
@model List<SharedLibraryCore.Dtos.ProfileMeta>
@model IEnumerable<SharedLibraryCore.Dtos.ProfileMeta>
@{
Layout = null;
@ -33,7 +33,7 @@
}
}
@if (Model.Count == 0)
@if (Model.Count() == 0)
{
<div class="p2 text-muted profile-event-timestep">@SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_CLIENT_META_NONE"]</div>
}

View File

@ -57,7 +57,10 @@
<div class="dropdown-menu p-0" aria-labelledby="account_dropdown">
<a asp-controller="Console" asp-action="Index" class="dropdown-item bg-dark text-muted text-center text-lg-left">@loc["WEBFRONT_NAV_CONSOLE"]</a>
<a asp-controller="Client" asp-action="ProfileAsync" asp-route-id="@ViewBag.User.ClientId" class="dropdown-item bg-dark text-muted text-center text-lg-left">@loc["WEBFRONT_NAV_PROFILE"]</a>
<a asp-controller="Configuration" asp-action="Edit" class="dropdown-item bg-dark text-muted text-center text-lg-left">@loc["WEBFRONT_NAV_EDIT_CONFIGURATION"]</a>
@if (ViewBag.User.Level == SharedLibraryCore.Database.Models.EFClient.Permission.Owner)
{
<a asp-controller="Configuration" asp-action="Edit" class="dropdown-item bg-dark text-muted text-center text-lg-left">@loc["WEBFRONT_NAV_EDIT_CONFIGURATION"]</a>
}
<a class="dropdown-item bg-dark text-muted text-center text-lg-left profile-action" href="#" data-action="GenerateLoginToken" title="@loc["WEBFRONT_ACTION_TOKEN"]">@loc["WEBFRONT_ACTION_TOKEN"]</a>
<a asp-controller="Account" asp-action="LogoutAsync" class="dropdown-item bg-dark text-muted text-center text-lg-left">@loc["WEBFRONT_NAV_LOGOUT"]</a>
</div>
@ -76,6 +79,7 @@
</div>
</nav>
</header>
<!-- loading icon -->
<div class="oi oi-loop-circular layout-loading-icon"></div>