Skip to content

Commit

Permalink
Merge branch 'master' into wm
Browse files Browse the repository at this point in the history
# Conflicts:
#	SS14
  • Loading branch information
Valtosin committed May 6, 2024
2 parents 3b73206 + ec05165 commit eb0ddcb
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "SS14"]
path = SS14
url = https://github.com/space-wizards/space-station-14.git
url = https://github.com/frosty-dev/ss14-core
2 changes: 1 addition & 1 deletion SS14
Submodule SS14 updated from bbf050 to 5b4164
17 changes: 17 additions & 0 deletions SS14.Admin/Helpers/BanHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Net.Sockets;
using Content.Server.Database;
using Microsoft.EntityFrameworkCore;
using SS14.Admin.Admins;
using NpgsqlTypes;

namespace SS14.Admin.Helpers;
Expand Down Expand Up @@ -165,6 +166,22 @@ public sealed class BanJoin<TBan, TUnban> where TBan: IBanCommon<TUnban> where T
}

ban.BanningAdmin = _httpContext.HttpContext!.User.Claims.GetUserId();

try
{
var adminData = _dbContext.Admin.First(a => a.UserId == ban.BanningAdmin);
var flags = AdminHelper.GetFlags(adminData);
if ((flags & AdminFlags.Ban) != flags)
{
return "Error: Admin doesn't have Ban flag.";
}
}
catch (Exception e)
{
_logger.LogError(e, "Unable to get admin flags");
return "Error: Unknown error occured while getting admin data.";;
}

ban.Reason = reason;
ban.BanTime = DateTime.UtcNow;
return null;
Expand Down
6 changes: 6 additions & 0 deletions SS14.Admin/LoginHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ public async Task HandleTokenValidated(TokenValidatedContext ctx)
}

var flags = AdminHelper.GetStringFlags(adminData);

/*if(!flags.Contains("BAN")) {
ctx.Response.Redirect(_linkGenerator.GetUriByPage(ctx.HttpContext, "/LoginFailed")!);
ctx.HandleResponse();
return;
}*/

foreach (var flag in flags)
{
Expand Down
2 changes: 1 addition & 1 deletion SS14.Admin/Pages/Bans/Index.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ await pagination.LoadLinqAsync(bans, e => e.Select(b =>
public sealed record Ban(
int Id,
Player? Player,
string? UserId,
string? PlayerUserId,
string? Address,
string? Hwid,
string Reason,
Expand Down
4 changes: 2 additions & 2 deletions SS14.Admin/Pages/LoginFailed.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
ViewData["Title"] = "Error";
}

<h1 class="text-danger">Failed to log in</h1>
<h2 class="text-danger">You are not a server administrator</h2>
<h1 class="text-danger">Ошибка входа</h1>
<h2 class="text-danger">Вы не являетесь администратором сервера.</h2>

2 changes: 1 addition & 1 deletion SS14.Admin/Pages/RoleBans/Index.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ await pagination.LoadLinqAsync(bans, e => e.Select(b =>
public sealed record RoleBan(
int Id,
Player? Player,
string? UserId,
string? PlayerUserId,
string? Address,
string? Hwid,
string Reason,
Expand Down
4 changes: 2 additions & 2 deletions SS14.Admin/Pages/Tables/BansTable.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@
<br/>
}
}
@if (ban.UserId != null)
@if (ban.PlayerUserId != null)
{
<small>
<strong>GUID:</strong> <span class="font-monospace">@ban.UserId</span>
<strong>GUID:</strong> <span class="font-monospace">@ban.PlayerUserId</span>
</small>
}
</td>
Expand Down
4 changes: 2 additions & 2 deletions SS14.Admin/Pages/Tables/RoleBansTable.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@
<br/>
}
}
@if (ban.UserId != null)
@if (ban.PlayerUserId != null)
{
<small>
<strong>GUID:</strong> <span class="font-monospace">@ban.UserId</span>
<strong>GUID:</strong> <span class="font-monospace">@ban.PlayerUserId</span>
</small>
}
</td>
Expand Down
5 changes: 5 additions & 0 deletions SS14.Admin/wwwroot/css/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ for details on configuring this project to bundle and minify static web assets.
--color-filter-type: #F78764;
}

* {
border-radius: 0 !important;
}

a.navbar-brand {
white-space: normal;
text-align: center;
Expand Down Expand Up @@ -91,6 +95,7 @@ html {
body {
/* Margin bottom by footer height */
margin-bottom: 60px;
font-family: Roboto, sans-serif;
}
.footer {
position: absolute;
Expand Down
Binary file modified SS14.Admin/wwwroot/favicon.ico
Binary file not shown.

0 comments on commit eb0ddcb

Please sign in to comment.