Truncate long name / job titles for IDs (#5009)
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Content.Shared.Access;
|
||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
@@ -40,6 +41,12 @@ namespace Content.Client.Access.UI
|
|||||||
|
|
||||||
public void SubmitData(string newFullName, string newJobTitle, List<string> newAccessList)
|
public void SubmitData(string newFullName, string newJobTitle, List<string> newAccessList)
|
||||||
{
|
{
|
||||||
|
if (newFullName.Length > MaxFullNameLength)
|
||||||
|
newFullName = newFullName[..MaxFullNameLength];
|
||||||
|
|
||||||
|
if (newJobTitle.Length > MaxJobTitleLength)
|
||||||
|
newJobTitle = newJobTitle[..MaxJobTitleLength];
|
||||||
|
|
||||||
SendMessage(new WriteToTargetIdMessage(
|
SendMessage(new WriteToTargetIdMessage(
|
||||||
newFullName,
|
newFullName,
|
||||||
newJobTitle,
|
newJobTitle,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Content.Server.Access.Components;
|
using Content.Server.Access.Components;
|
||||||
|
using Content.Shared.Access;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
|
|
||||||
@@ -23,6 +24,10 @@ namespace Content.Server.Access.Systems
|
|||||||
if (!Resolve(uid, ref id))
|
if (!Resolve(uid, ref id))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// TODO: Whenever we get admin logging these should be logged
|
||||||
|
if (jobTitle.Length > SharedIdCardConsoleComponent.MaxJobTitleLength)
|
||||||
|
jobTitle = jobTitle[..SharedIdCardConsoleComponent.MaxJobTitleLength];
|
||||||
|
|
||||||
id.JobTitle = jobTitle;
|
id.JobTitle = jobTitle;
|
||||||
UpdateEntityName(uid, id);
|
UpdateEntityName(uid, id);
|
||||||
return true;
|
return true;
|
||||||
@@ -33,6 +38,9 @@ namespace Content.Server.Access.Systems
|
|||||||
if (!Resolve(uid, ref id))
|
if (!Resolve(uid, ref id))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (fullName.Length > SharedIdCardConsoleComponent.MaxFullNameLength)
|
||||||
|
fullName = fullName[..SharedIdCardConsoleComponent.MaxFullNameLength];
|
||||||
|
|
||||||
id.FullName = fullName;
|
id.FullName = fullName;
|
||||||
UpdateEntityName(uid, id);
|
UpdateEntityName(uid, id);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ namespace Content.Shared.Access
|
|||||||
{
|
{
|
||||||
public override string Name => "IdCardConsole";
|
public override string Name => "IdCardConsole";
|
||||||
|
|
||||||
|
public const int MaxFullNameLength = 256;
|
||||||
|
public const int MaxJobTitleLength = 256;
|
||||||
|
|
||||||
public enum UiButton
|
public enum UiButton
|
||||||
{
|
{
|
||||||
PrivilegedId,
|
PrivilegedId,
|
||||||
|
|||||||
Reference in New Issue
Block a user