Обнова авторизации и поддержка гитхаба
This commit is contained in:
parent
ee3f9c4156
commit
ff247f6cac
14 changed files with 116 additions and 33 deletions
|
|
@ -6,41 +6,41 @@
|
||||||
<customControls:HSeparator/>
|
<customControls:HSeparator/>
|
||||||
<BoxContainer Orientation="Horizontal" SeparationOverride="2" HorizontalExpand="True">
|
<BoxContainer Orientation="Horizontal" SeparationOverride="2" HorizontalExpand="True">
|
||||||
<customControls:VSeparator/>
|
<customControls:VSeparator/>
|
||||||
<BoxContainer Orientation="Vertical" HorizontalExpand="True">
|
<BoxContainer Orientation="Vertical" SizeFlagsStretchRatio="2" HorizontalExpand="True" HorizontalAlignment="Center">
|
||||||
<Label Text="{Loc 'user-profile-sponsor-title'}" StyleClasses="LabelHeadingBigger" HorizontalAlignment="Center"/>
|
<Label Text="{Loc 'user-profile-sponsor-title'}" StyleClasses="LabelHeadingBigger" HorizontalAlignment="Center"/>
|
||||||
<GridContainer Columns="2"
|
<BoxContainer Orientation="Vertical" HorizontalExpand="True" HorizontalAlignment="Center">
|
||||||
HorizontalAlignment="Center"
|
|
||||||
VerticalExpand="True"
|
|
||||||
VerticalAlignment="Top"
|
|
||||||
Margin="5 5 5 5">
|
|
||||||
<Label Text="{Loc 'user-profile-level'}" StyleClasses="LabelKeyText"/>
|
<Label Text="{Loc 'user-profile-level'}" StyleClasses="LabelKeyText"/>
|
||||||
<Label Name="SponsorTierName" />
|
<Label Name="SponsorTierName" Margin="5 0 0 0"/>
|
||||||
</GridContainer>
|
</BoxContainer>
|
||||||
<GridContainer Columns="2"
|
<Button Name="InfoSponsorButton" Margin="0 2 0 0" Text="{Loc 'user-profile-sponsor-info-button'}" HorizontalAlignment="Center" />
|
||||||
HorizontalAlignment="Center"
|
<Button Name="BuySponsorButton" Margin="0 2 0 0" Text="{Loc 'user-profile-sponsor-buy-button'}" HorizontalAlignment="Center" />
|
||||||
VerticalExpand="True"
|
|
||||||
VerticalAlignment="Top">
|
|
||||||
<Button Name="InfoSponsorButton" Text="{Loc 'user-profile-sponsor-info-button'}" />
|
|
||||||
<Button Name="BuySponsorButton" Text="{Loc 'user-profile-sponsor-buy-button'}" />
|
|
||||||
</GridContainer>
|
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
<customControls:VSeparator/>
|
<customControls:VSeparator/>
|
||||||
<BoxContainer Orientation="Vertical" HorizontalExpand="True">
|
<BoxContainer Orientation="Vertical" SizeFlagsStretchRatio="3" HorizontalExpand="True" Margin="5 5 5 5">
|
||||||
<Label Text="{Loc 'user-profile-social-links'}" StyleClasses="LabelHeadingBigger" HorizontalAlignment="Center"/>
|
<Label Text="{Loc 'user-profile-social-links'}" StyleClasses="LabelHeadingBigger" HorizontalAlignment="Center"/>
|
||||||
<GridContainer Columns="2"
|
<GridContainer Columns="3"
|
||||||
HorizontalAlignment="Center"
|
Rows="3"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
VerticalExpand="True"
|
VerticalExpand="True"
|
||||||
VerticalAlignment="Top"
|
HorizontalExpand="True"
|
||||||
Margin="5 5 5 5">
|
VerticalAlignment="Top">
|
||||||
<Label Text="{Loc 'user-profile-service-discord'}" StyleClasses="LabelKeyText"/>
|
<Label Text="{Loc 'user-profile-service-discord'}" HorizontalExpand="True" HorizontalAlignment="Left" StyleClasses="LabelKeyText"/>
|
||||||
<BoxContainer Orientation="Horizontal">
|
<Label Text="{Loc 'user-profile-service-telegram'}" HorizontalExpand="True" HorizontalAlignment="Left" StyleClasses="LabelKeyText"/>
|
||||||
<Label Name="LinkedDiscordName" />
|
<Label Text="{Loc 'user-profile-service-github'}" HorizontalExpand="True" HorizontalAlignment="Left" StyleClasses="LabelKeyText"/>
|
||||||
<Button Name="LinkDiscordButton" Text="{Loc 'user-profile-service-link'}"/>
|
<Label Name="LinkedDiscordName" HorizontalExpand="True" HorizontalAlignment="Center"/>
|
||||||
|
<Label Name="LinkedTelegramName" HorizontalExpand="True" HorizontalAlignment="Center"/>
|
||||||
|
<Label Name="LinkedGitHubName" HorizontalExpand="True" HorizontalAlignment="Center"/>
|
||||||
|
<BoxContainer Orientation="Horizontal" HorizontalExpand="True" HorizontalAlignment="Right">
|
||||||
|
<Button Name="LinkDiscordButton" Text="{Loc 'user-profile-service-link'}" HorizontalExpand="True" HorizontalAlignment="Stretch" />
|
||||||
|
<Button Name="ResetDiscordButton" Text="{Loc 'user-profile-service-reset'}" HorizontalExpand="True" HorizontalAlignment="Stretch" Visible="False"/>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
<Label Text="{Loc 'user-profile-service-telegram'}" StyleClasses="LabelKeyText"/>
|
<BoxContainer Orientation="Horizontal" HorizontalExpand="True" HorizontalAlignment="Right">
|
||||||
<BoxContainer Orientation="Horizontal" >
|
<Button Name="LinkTelegramButton" Text="{Loc 'user-profile-service-link'}" HorizontalExpand="True" HorizontalAlignment="Stretch" />
|
||||||
<Label Name="LinkedTelegramName" />
|
<Button Name="ResetTelegramButton" Text="{Loc 'user-profile-service-reset'}" HorizontalExpand="True" HorizontalAlignment="Stretch" Visible="False"/>
|
||||||
<Button Name="LinkTelegramButton" Text="{Loc 'user-profile-service-link'}"/>
|
</BoxContainer>
|
||||||
|
<BoxContainer Orientation="Horizontal" HorizontalExpand="True" HorizontalAlignment="Right">
|
||||||
|
<Button Name="LinkGitHubButton" Text="{Loc 'user-profile-service-link'}" HorizontalExpand="True" HorizontalAlignment="Stretch" />
|
||||||
|
<Button Name="ResetGitHubButton" Text="{Loc 'user-profile-service-reset'}" HorizontalExpand="True" HorizontalAlignment="Stretch" Visible="False"/>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
</GridContainer>
|
</GridContainer>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
|
|
|
||||||
|
|
@ -42,11 +42,16 @@ public sealed partial class UserProfile : Control
|
||||||
{
|
{
|
||||||
LinkDiscordButton.Disabled = true;
|
LinkDiscordButton.Disabled = true;
|
||||||
LinkTelegramButton.Disabled = true;
|
LinkTelegramButton.Disabled = true;
|
||||||
|
LinkGitHubButton.Disabled = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LinkTelegramButton.OnPressed += LinkTelegramPressed;
|
LinkTelegramButton.OnPressed += LinkTelegramPressed;
|
||||||
LinkDiscordButton.OnPressed += LinkDiscordPressed;
|
LinkDiscordButton.OnPressed += LinkDiscordPressed;
|
||||||
|
LinkGitHubButton.OnPressed += LinkGitHubPressed;
|
||||||
|
ResetTelegramButton.OnPressed += ResetTelegramPressed;
|
||||||
|
ResetDiscordButton.OnPressed += ResetDiscordPressed;
|
||||||
|
ResetGitHubButton.OnPressed += ResetGitHubPressed;
|
||||||
_serviceAuthManager.LoadedServiceLinkedServices += RefreshServiceLinkedServices;
|
_serviceAuthManager.LoadedServiceLinkedServices += RefreshServiceLinkedServices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -93,22 +98,67 @@ public sealed partial class UserProfile : Control
|
||||||
if (_serviceAuthManager == null)
|
if (_serviceAuthManager == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (var serviceAuthData in _serviceAuthManager.ServiceLinkedServices)
|
// Reset visibility and text for all services
|
||||||
|
LinkDiscordButton.Visible = true;
|
||||||
|
LinkedDiscordName.Text = string.Empty;
|
||||||
|
ResetDiscordButton.Visible = false;
|
||||||
|
|
||||||
|
LinkTelegramButton.Visible = true;
|
||||||
|
LinkedTelegramName.Text = string.Empty;
|
||||||
|
ResetTelegramButton.Visible = false;
|
||||||
|
|
||||||
|
LinkGitHubButton.Visible = true;
|
||||||
|
LinkedGitHubName.Text = string.Empty;
|
||||||
|
ResetGitHubButton.Visible = false;
|
||||||
|
|
||||||
|
// Update visibility and text based on linked services
|
||||||
|
foreach (var serviceAuthData in linkedServices)
|
||||||
{
|
{
|
||||||
switch (serviceAuthData.ServiceType)
|
switch (serviceAuthData.ServiceType)
|
||||||
{
|
{
|
||||||
case ServiceType.Discord:
|
case ServiceType.Discord:
|
||||||
LinkDiscordButton.Visible = false;
|
LinkDiscordButton.Visible = false;
|
||||||
LinkedDiscordName.Text = serviceAuthData.Username;
|
LinkedDiscordName.Text = serviceAuthData.Username;
|
||||||
|
ResetDiscordButton.Visible = true;
|
||||||
break;
|
break;
|
||||||
case ServiceType.Telegram:
|
case ServiceType.Telegram:
|
||||||
LinkTelegramButton.Visible = false;
|
LinkTelegramButton.Visible = false;
|
||||||
LinkedTelegramName.Text = serviceAuthData.Username;
|
LinkedTelegramName.Text = serviceAuthData.Username;
|
||||||
|
ResetTelegramButton.Visible = true;
|
||||||
|
break;
|
||||||
|
case ServiceType.Github:
|
||||||
|
LinkGitHubButton.Visible = false;
|
||||||
|
LinkedGitHubName.Text = serviceAuthData.Username;
|
||||||
|
ResetGitHubButton.Visible = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ResetTelegramPressed(BaseButton.ButtonEventArgs obj)
|
||||||
|
{
|
||||||
|
if (_serviceAuthManager == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_serviceAuthManager.ResetServiceLink(ServiceType.Telegram);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ResetDiscordPressed(BaseButton.ButtonEventArgs obj)
|
||||||
|
{
|
||||||
|
if (_serviceAuthManager == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_serviceAuthManager.ResetServiceLink(ServiceType.Discord);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ResetGitHubPressed(BaseButton.ButtonEventArgs obj)
|
||||||
|
{
|
||||||
|
if (_serviceAuthManager == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_serviceAuthManager.ResetServiceLink(ServiceType.Github);
|
||||||
|
}
|
||||||
|
|
||||||
private void BuySponsorPressed(BaseButton.ButtonEventArgs obj)
|
private void BuySponsorPressed(BaseButton.ButtonEventArgs obj)
|
||||||
{
|
{
|
||||||
_uri.OpenUri(_donateUrl);
|
_uri.OpenUri(_donateUrl);
|
||||||
|
|
@ -130,6 +180,14 @@ public sealed partial class UserProfile : Control
|
||||||
_serviceAuthManager.ToggleWindow(ServiceType.Discord);
|
_serviceAuthManager.ToggleWindow(ServiceType.Discord);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LinkGitHubPressed(BaseButton.ButtonEventArgs obj)
|
||||||
|
{
|
||||||
|
if (_serviceAuthManager == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_serviceAuthManager.ToggleWindow(ServiceType.Github);
|
||||||
|
}
|
||||||
|
|
||||||
private void InfoSponsorPressed(BaseButton.ButtonEventArgs obj)
|
private void InfoSponsorPressed(BaseButton.ButtonEventArgs obj)
|
||||||
{
|
{
|
||||||
_sponsorTiersUIController.ToggleWindow();
|
_sponsorTiersUIController.ToggleWindow();
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,9 @@ public sealed class SunriseCCVars
|
||||||
public static readonly CVarDef<bool> ServiceAuthCheckDiscordMember =
|
public static readonly CVarDef<bool> ServiceAuthCheckDiscordMember =
|
||||||
CVarDef.Create("service_auth.check_discord_member", false, CVar.SERVERONLY);
|
CVarDef.Create("service_auth.check_discord_member", false, CVar.SERVERONLY);
|
||||||
|
|
||||||
|
public static readonly CVarDef<string> ServiceAuthProjectName =
|
||||||
|
CVarDef.Create("service_auth.project_name", string.Empty, CVar.SERVERONLY);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GodMode RoundEnd
|
* GodMode RoundEnd
|
||||||
*/
|
*/
|
||||||
|
|
@ -114,6 +117,9 @@ public sealed class SunriseCCVars
|
||||||
public static readonly CVarDef<string> SponsorGhostTheme =
|
public static readonly CVarDef<string> SponsorGhostTheme =
|
||||||
CVarDef.Create("sponsor.ghost_theme", "", CVar.CLIENTONLY | CVar.ARCHIVE);
|
CVarDef.Create("sponsor.ghost_theme", "", CVar.CLIENTONLY | CVar.ARCHIVE);
|
||||||
|
|
||||||
|
public static readonly CVarDef<string> SponsorProjectName =
|
||||||
|
CVarDef.Create("sponsor.project_name", string.Empty, CVar.SERVERONLY);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Greetings
|
* Greetings
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -12692,3 +12692,17 @@
|
||||||
id: 870
|
id: 870
|
||||||
time: '2025-02-15T21:25:57.0000000+00:00'
|
time: '2025-02-15T21:25:57.0000000+00:00'
|
||||||
url: https://github.com/space-sunrise/space-station-14/pull/1383
|
url: https://github.com/space-sunrise/space-station-14/pull/1383
|
||||||
|
- author: VigersRay
|
||||||
|
changes:
|
||||||
|
- message: "\u0414\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u0430 \u043F\u043E\u0434\
|
||||||
|
\u0434\u0435\u0440\u0436\u043A\u0430 \u043F\u043E\u0434\u0432\u044F\u0437\u043A\
|
||||||
|
\u0438 \u0433\u0438\u0442\u0445\u0430\u0431\u0430."
|
||||||
|
type: Tweak
|
||||||
|
- message: "\u0414\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u0430 \u0432\u043E\u0437\
|
||||||
|
\u043C\u043E\u0436\u043D\u043E\u0441\u0442\u044C \u043E\u0442\u0432\u044F\u0437\
|
||||||
|
\u044B\u0432\u0430\u0442\u044C \u043F\u0440\u0438\u0432\u044F\u0437\u0430\u043D\
|
||||||
|
\u044B\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044B \u0432 \u043B\u043E\u0431\
|
||||||
|
\u0431\u0438."
|
||||||
|
type: Tweak
|
||||||
|
id: 871
|
||||||
|
time: '2025-02-19T09:22:50.888586+00:00'
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
service-auth-discord-title = Авторизация Discord
|
service-auth-discord-title = Авторизация Discord
|
||||||
service-auth-telegram-title = Авторизация Telegram
|
service-auth-telegram-title = Авторизация Telegram
|
||||||
|
service-auth-github-title = Авторизация GitHub
|
||||||
service-auth-select-service-title = Выбор сервиса авторизации
|
service-auth-select-service-title = Выбор сервиса авторизации
|
||||||
service-auth-select-service = Для доступа на сервер вам необходимо связать аккаунт SS14 c одним из сервисов.
|
service-auth-select-service = Для доступа на сервер вам необходимо связать аккаунт SS14 c одним из сервисов.
|
||||||
service-auth-warn1 = Советуем вам делать привязку на основной аккаунт.
|
service-auth-warn1 = Советуем вам делать привязку на основной аккаунт.
|
||||||
|
|
|
||||||
|
|
@ -7,3 +7,5 @@ user-profile-sponsor-buy-button = Приобрести
|
||||||
user-profile-service-link = Подвязать
|
user-profile-service-link = Подвязать
|
||||||
user-profile-service-discord = Discord:
|
user-profile-service-discord = Discord:
|
||||||
user-profile-service-telegram = Telegram:
|
user-profile-service-telegram = Telegram:
|
||||||
|
user-profile-service-github = GitHub:
|
||||||
|
user-profile-service-reset = Отвязать
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
service-auth-discord-title = Авторизация Discord
|
service-auth-discord-title = Авторизация Discord
|
||||||
service-auth-telegram-title = Авторизация Telegram
|
service-auth-telegram-title = Авторизация Telegram
|
||||||
|
service-auth-github-title = Авторизация GitHub
|
||||||
service-auth-select-service-title = Выбор сервиса авторизации
|
service-auth-select-service-title = Выбор сервиса авторизации
|
||||||
service-auth-select-service = Для доступа на сервер вам необходимо связать аккаунт SS14 c одним из сервисов.
|
service-auth-select-service = Для доступа на сервер вам необходимо связать аккаунт SS14 c одним из сервисов.
|
||||||
service-auth-warn1 = Советуем вам делать привязку на основной аккаунт.
|
service-auth-warn1 = Советуем вам делать привязку на основной аккаунт.
|
||||||
|
|
|
||||||
|
|
@ -7,3 +7,5 @@ user-profile-sponsor-buy-button = Приобрести
|
||||||
user-profile-service-link = Подвязать
|
user-profile-service-link = Подвязать
|
||||||
user-profile-service-discord = Discord:
|
user-profile-service-discord = Discord:
|
||||||
user-profile-service-telegram = Telegram:
|
user-profile-service-telegram = Telegram:
|
||||||
|
user-profile-service-github = GitHub:
|
||||||
|
user-profile-service-reset = Отвязать
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 141 KiB After Width: | Height: | Size: 454 B |
BIN
Resources/Textures/_Sunrise/ServiceAuth/github_icon.png
Normal file
BIN
Resources/Textures/_Sunrise/ServiceAuth/github_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 181 B |
Binary file not shown.
|
Before Width: | Height: | Size: 108 KiB After Width: | Height: | Size: 1.9 KiB |
|
|
@ -9,4 +9,5 @@ public interface IClientServiceAuthManager : ISharedServiceAuthManager
|
||||||
public event Action<List<LinkedServiceData>>? LoadedServiceLinkedServices;
|
public event Action<List<LinkedServiceData>>? LoadedServiceLinkedServices;
|
||||||
public event Action<ServiceAuthData>? LoadedAuthData;
|
public event Action<ServiceAuthData>? LoadedAuthData;
|
||||||
public void ToggleWindow(ServiceType serviceType);
|
public void ToggleWindow(ServiceType serviceType);
|
||||||
|
public void ResetServiceLink(ServiceType serviceType);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,6 @@ namespace Content.Sunrise.Interfaces.Server;
|
||||||
public interface IServerServiceAuthManager : ISharedServiceAuthManager
|
public interface IServerServiceAuthManager : ISharedServiceAuthManager
|
||||||
{
|
{
|
||||||
public event EventHandler<ICommonSession>? PlayerVerified;
|
public event EventHandler<ICommonSession>? PlayerVerified;
|
||||||
public Task<ServiceAuthDataResponse?> GenerateDiscordAuthData(NetUserId userId, CancellationToken cancel);
|
|
||||||
public Task<ServiceAuthDataResponse?> GenerateTelegramAuthData(NetUserId userId, CancellationToken cancel);
|
|
||||||
public Task<List<LinkedServiceData>> CheckLinkedServices(NetUserId userId, string username, CancellationToken cancel);
|
|
||||||
public Task<string?> GetDiscordUserId(NetUserId? userId, CancellationToken cancel = default);
|
public Task<string?> GetDiscordUserId(NetUserId? userId, CancellationToken cancel = default);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,8 @@ public sealed record ServiceAuthDataResponse(string Url, byte[] Qrcode);
|
||||||
public enum ServiceType
|
public enum ServiceType
|
||||||
{
|
{
|
||||||
Discord,
|
Discord,
|
||||||
Telegram
|
Telegram,
|
||||||
|
Github
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class ServiceAuthData(string url, byte[] qrcode, ServiceType serviceType)
|
public sealed class ServiceAuthData(string url, byte[] qrcode, ServiceType serviceType)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue