diff --git a/Content.Server/Administration/Managers/BanManager.cs b/Content.Server/Administration/Managers/BanManager.cs index d1e9264799..406d62ee89 100644 --- a/Content.Server/Administration/Managers/BanManager.cs +++ b/Content.Server/Administration/Managers/BanManager.cs @@ -51,7 +51,7 @@ public sealed partial class BanManager : IBanManager, IPostInjectInit [Dependency] private readonly ITaskManager _taskManager = default!; [Dependency] private readonly UserDbDataManager _userDbData = default!; - private IServerDiscordAuthManager? _discordAuth; // Sunrise-Edit + private IServerServiceAuthManager? _serviceAuth; // Sunrise-Edit private ISawmill _sawmill = default!; public const string SawmillId = "admin.bans"; @@ -84,7 +84,7 @@ public sealed partial class BanManager : IBanManager, IPostInjectInit _cfg.OnValueChanged(SunriseCCVars.DiscordBanWebhook, OnWebhookChanged, true); _cfg.OnValueChanged(CVars.GameHostName, OnServerNameChanged, true); - IoCManager.Instance!.TryResolveType(out _discordAuth); + IoCManager.Instance!.TryResolveType(out _serviceAuth); // Sunrise-End } @@ -487,10 +487,10 @@ public sealed partial class BanManager : IBanManager, IPostInjectInit string? adminDiscordId = null; string? targetDiscordId = null; - if (_discordAuth != null) + if (_serviceAuth != null) { - adminDiscordId = await _discordAuth.GetDiscordUserId(banDef.BanningAdmin); - targetDiscordId = await _discordAuth.GetDiscordUserId(banDef.UserId); + adminDiscordId = await _serviceAuth.GetDiscordUserId(banDef.BanningAdmin); + targetDiscordId = await _serviceAuth.GetDiscordUserId(banDef.UserId); } var adminLink = ""; @@ -620,10 +620,10 @@ public sealed partial class BanManager : IBanManager, IPostInjectInit string? adminDiscordId = null; string? targetDiscordId = null; - if (_discordAuth != null) + if (_serviceAuth != null) { - adminDiscordId = await _discordAuth.GetDiscordUserId(banDef.BanningAdmin); - targetDiscordId = await _discordAuth.GetDiscordUserId(banDef.UserId); + adminDiscordId = await _serviceAuth.GetDiscordUserId(banDef.BanningAdmin); + targetDiscordId = await _serviceAuth.GetDiscordUserId(banDef.UserId); } var adminLink = ""; diff --git a/Content.Shared/_Sunrise/SunriseCCVars/SunriseCCVars.cs b/Content.Shared/_Sunrise/SunriseCCVars/SunriseCCVars.cs index cac963ebe1..2c328eeb64 100644 --- a/Content.Shared/_Sunrise/SunriseCCVars/SunriseCCVars.cs +++ b/Content.Shared/_Sunrise/SunriseCCVars/SunriseCCVars.cs @@ -59,20 +59,23 @@ public sealed class SunriseCCVars CVarDef.Create("discord.ban_webhook", string.Empty, CVar.SERVERONLY); /* - * Discord Auth + * Service Authorization */ - public static readonly CVarDef DiscordAuthEnabled = - CVarDef.Create("discord_auth.enabled", false, CVar.SERVERONLY); + public static readonly CVarDef ServiceAuthEnabled = + CVarDef.Create("service_auth.enabled", false, CVar.SERVERONLY); - public static readonly CVarDef DiscordAuthApiUrl = - CVarDef.Create("discord_auth.api_url", "", CVar.SERVERONLY); + public static readonly CVarDef ServiceAuthApiUrl = + CVarDef.Create("service_auth.api_url", "", CVar.SERVERONLY); - public static readonly CVarDef DiscordAuthApiToken = - CVarDef.Create("discord_auth.api_token", "", CVar.SERVERONLY | CVar.CONFIDENTIAL); + public static readonly CVarDef ServiceAuthApiToken = + CVarDef.Create("service_auth.api_token", "", CVar.SERVERONLY | CVar.CONFIDENTIAL); - public static readonly CVarDef DiscordAuthCheckMember = - CVarDef.Create("discord_auth.check_member", false, CVar.SERVERONLY); + public static readonly CVarDef ServiceAuthCheckTelegramMember = + CVarDef.Create("service_auth.check_telegram_member", false, CVar.SERVERONLY); + + public static readonly CVarDef ServiceAuthCheckDiscordMember = + CVarDef.Create("service_auth.check_discord_member", false, CVar.SERVERONLY); /* * GodMode RoundEnd @@ -164,12 +167,22 @@ public sealed class SunriseCCVars public static readonly CVarDef TapePlayerClientEnabled = CVarDef.Create("tape_player.client_enabled", true, CVar.CLIENTONLY | CVar.ARCHIVE); + /* + * INFOLINKS + */ + /// /// Link to boosty to show in the launcher. /// public static readonly CVarDef InfoLinksDonate = CVarDef.Create("infolinks.donate", "", CVar.SERVER | CVar.REPLICATED); + /// + /// Link to Telegram channel to show in the launcher. + /// + public static readonly CVarDef InfoLinksTelegram = + CVarDef.Create("infolinks.telegram", "", CVar.SERVER | CVar.REPLICATED); + /** * Lobby */ diff --git a/Resources/Locale/ru-RU/_sunrise/join-queue/queue-screen.ftl b/Resources/Locale/ru-RU/_sunrise/join-queue/queue-screen.ftl new file mode 100644 index 0000000000..ece8a6e941 --- /dev/null +++ b/Resources/Locale/ru-RU/_sunrise/join-queue/queue-screen.ftl @@ -0,0 +1,5 @@ +queue-title = Очередь +queue-quit = Выйти +queue-position = Ваша позиция: +queue-total = Всего в очереди: +queue-priority-join = Приоритетный вход diff --git a/Resources/Locale/ru-RU/_sunrise/service-auth/service-auth-state.ftl b/Resources/Locale/ru-RU/_sunrise/service-auth/service-auth-state.ftl new file mode 100644 index 0000000000..379788e0b2 --- /dev/null +++ b/Resources/Locale/ru-RU/_sunrise/service-auth/service-auth-state.ftl @@ -0,0 +1,12 @@ +service-auth-discord-title = Авторизация Discord +service-auth-telegram-title = Авторизация Telegram +service-auth-select-service-title = Выбор сервиса авторизации +service-auth-select-service = Для доступа на сервер вам необходимо связать аккаунт SS14 c одним из сервисов. +service-auth-warn1 = Советуем вам делать привязку на основной аккаунт. +service-auth-warn2 = Будьте внимательны при выборе аккаунта. +service-auth-browser-btn = Открыть в браузере +service-auth-quit-btn = Выйти +service-auth-qrcode = QrCode для сканирования на телефоне. +service-auth-check-btn = Проверить +service-auth-check-btn-wait = Ожидайте: { TOSTRING($time, "G3") } +service-auth-switch-link-service = Выбрать другой сервис diff --git a/Resources/Locale/ru-RU/_sunrise/service-auth/service-member-state.ftl b/Resources/Locale/ru-RU/_sunrise/service-auth/service-member-state.ftl new file mode 100644 index 0000000000..ed1a129fa8 --- /dev/null +++ b/Resources/Locale/ru-RU/_sunrise/service-auth/service-member-state.ftl @@ -0,0 +1,8 @@ +service-check-member-title = Проверка членства в Discord +service-check-member-info = Для доступа на сервер вам необходимо быть участником нашего Discord сервера. +service-check-member-warn = Учтите что зайти на сервер нужно с того аккаунта на который вы делали подвязку. +service-check-member-username = Ваш подвязаный аккаунт: +service-check-member-browser-btn = Открыть в браузере +service-check-member-quit-btn = Выйти +service-check-member-qrcode = QrCode для сканирования на телефоне. +service-check-member-check-btn = Проверить diff --git a/Resources/Textures/_Sunrise/ServiceAuth/discord_icon.png b/Resources/Textures/_Sunrise/ServiceAuth/discord_icon.png new file mode 100644 index 0000000000..15c92b83ee Binary files /dev/null and b/Resources/Textures/_Sunrise/ServiceAuth/discord_icon.png differ diff --git a/Resources/Textures/_Sunrise/ServiceAuth/telegram_icon.png b/Resources/Textures/_Sunrise/ServiceAuth/telegram_icon.png new file mode 100644 index 0000000000..d9fba50a0a Binary files /dev/null and b/Resources/Textures/_Sunrise/ServiceAuth/telegram_icon.png differ diff --git a/Resources/Textures/_Sunrise/test.png b/Resources/Textures/_Sunrise/test.png new file mode 100644 index 0000000000..0078fd489c Binary files /dev/null and b/Resources/Textures/_Sunrise/test.png differ diff --git a/Sunrise/Content.Sunrise.Interfaces.Client/Content.Sunrise.Interfaces.Client.csproj b/Sunrise/Content.Sunrise.Interfaces.Client/Content.Sunrise.Interfaces.Client.csproj index 792b49fe44..fdb4414bea 100644 --- a/Sunrise/Content.Sunrise.Interfaces.Client/Content.Sunrise.Interfaces.Client.csproj +++ b/Sunrise/Content.Sunrise.Interfaces.Client/Content.Sunrise.Interfaces.Client.csproj @@ -10,4 +10,7 @@ + + + diff --git a/Sunrise/Content.Sunrise.Interfaces.Client/IClientDiscordAuthManager.cs b/Sunrise/Content.Sunrise.Interfaces.Client/IClientDiscordAuthManager.cs deleted file mode 100644 index 1356040bce..0000000000 --- a/Sunrise/Content.Sunrise.Interfaces.Client/IClientDiscordAuthManager.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Content.Sunrise.Interfaces.Shared; -using Robust.Client.Graphics; - -namespace Content.Sunrise.Interfaces.Client; - -public interface IClientDiscordAuthManager : ISharedDiscordAuthManager -{ - public string AuthUrl { get; } - public Texture? Qrcode { get; } - public string DiscordUrl { get; } - public Texture? DiscordQrcode { get; } - public string DiscordUsername { get; } -} diff --git a/Sunrise/Content.Sunrise.Interfaces.Client/IClientServiceAuthManager.cs b/Sunrise/Content.Sunrise.Interfaces.Client/IClientServiceAuthManager.cs new file mode 100644 index 0000000000..2494fadcdf --- /dev/null +++ b/Sunrise/Content.Sunrise.Interfaces.Client/IClientServiceAuthManager.cs @@ -0,0 +1,12 @@ +using Content.Sunrise.Interfaces.Shared; +using Robust.Client.Graphics; + +namespace Content.Sunrise.Interfaces.Client; + +public interface IClientServiceAuthManager : ISharedServiceAuthManager +{ + public string ServiceJoinUrl { get; } + public Texture? ServiceJoinQrcode { get; } + public string ServiceUsername { get; } + public List ServiceAuthDatas { get; set; } +} diff --git a/Sunrise/Content.Sunrise.Interfaces.Server/IServerDiscordAuthManager.cs b/Sunrise/Content.Sunrise.Interfaces.Server/IServerDiscordAuthManager.cs index 265e0c196e..1d10f23bc4 100644 --- a/Sunrise/Content.Sunrise.Interfaces.Server/IServerDiscordAuthManager.cs +++ b/Sunrise/Content.Sunrise.Interfaces.Server/IServerDiscordAuthManager.cs @@ -4,14 +4,12 @@ using Robust.Shared.Player; namespace Content.Sunrise.Interfaces.Server; -public interface IServerDiscordAuthManager : ISharedDiscordAuthManager +public interface IServerServiceAuthManager : ISharedServiceAuthManager { public event EventHandler? PlayerVerified; - public Task GenerateAuthLink(NetUserId userId, string username, CancellationToken cancel); - public Task IsVerified(NetUserId userId, CancellationToken cancel); + public Task GenerateDiscordAuthData(NetUserId userId, CancellationToken cancel); + public Task GenerateTelegramAuthData(NetUserId userId, CancellationToken cancel); + public Task> CheckLinkedServices(NetUserId userId, string username, CancellationToken cancel); public Task GetDiscordUserId(NetUserId? userId, CancellationToken cancel = default); - } -public sealed record DiscordLinkResponse(string Url, byte[] Qrcode); -public sealed record DiscordGenerateLinkResponse(string Url, byte[] Qrcode); diff --git a/Sunrise/Content.Sunrise.Interfaces.Shared/Content.Sunrise.Interfaces.Shared.csproj b/Sunrise/Content.Sunrise.Interfaces.Shared/Content.Sunrise.Interfaces.Shared.csproj index 5c1a9adff9..00388b0bd8 100644 --- a/Sunrise/Content.Sunrise.Interfaces.Shared/Content.Sunrise.Interfaces.Shared.csproj +++ b/Sunrise/Content.Sunrise.Interfaces.Shared/Content.Sunrise.Interfaces.Shared.csproj @@ -7,4 +7,7 @@ + + + diff --git a/Sunrise/Content.Sunrise.Interfaces.Shared/ISharedDiscordAuthManager.cs b/Sunrise/Content.Sunrise.Interfaces.Shared/ISharedDiscordAuthManager.cs deleted file mode 100644 index 73c16bc091..0000000000 --- a/Sunrise/Content.Sunrise.Interfaces.Shared/ISharedDiscordAuthManager.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Content.Sunrise.Interfaces.Shared; - -public interface ISharedDiscordAuthManager -{ - public void Initialize(); -} diff --git a/Sunrise/Content.Sunrise.Interfaces.Shared/ISharedServiceAuthManager.cs b/Sunrise/Content.Sunrise.Interfaces.Shared/ISharedServiceAuthManager.cs new file mode 100644 index 0000000000..c5f0f444d5 --- /dev/null +++ b/Sunrise/Content.Sunrise.Interfaces.Shared/ISharedServiceAuthManager.cs @@ -0,0 +1,22 @@ +namespace Content.Sunrise.Interfaces.Shared; + +public interface ISharedServiceAuthManager +{ + public void Initialize(); +} + +public sealed record ServiceLinkResponse(string Url, byte[] Qrcode); +public sealed record ServiceAuthDataResponse(string Url, byte[] Qrcode); + +public enum ServiceType +{ + Discord, + Telegram +} + +public sealed class ServiceAuthData(string url, byte[] qrcode, ServiceType serviceType) +{ + public string Url { get; set; } = url; + public byte[] QrCode { get; set; } = qrcode; + public ServiceType ServiceType { get; set; } = serviceType; +}