use nullorempty
This commit is contained in:
@@ -196,7 +196,7 @@ public class ServerConfigurationManager
|
||||
public string GetDiscordUserFromToken(ServerStorage server)
|
||||
{
|
||||
JwtSecurityTokenHandler handler = new JwtSecurityTokenHandler();
|
||||
if (server.OAuthToken == null) return string.Empty;
|
||||
if (string.IsNullOrEmpty(server.OAuthToken)) return string.Empty;
|
||||
try
|
||||
{
|
||||
var token = handler.ReadJwtToken(server.OAuthToken);
|
||||
|
||||
@@ -284,7 +284,7 @@ public partial class IntroUi : WindowMediatorSubscriberBase
|
||||
}
|
||||
else
|
||||
{
|
||||
if (selectedServer.OAuthToken == null)
|
||||
if (string.IsNullOrEmpty(selectedServer.OAuthToken))
|
||||
{
|
||||
UiSharedService.TextWrapped("Press the button below to verify the server has OAuth2 capabilities. Afterwards, authenticate using Discord in the Browser window.");
|
||||
_uiShared.DrawOAuth(selectedServer);
|
||||
|
||||
@@ -1447,7 +1447,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
|
||||
" Make sure to enter the character names correctly or use the 'Add current character' button at the bottom.", ImGuiColors.DalamudYellow);
|
||||
int i = 0;
|
||||
_uiShared.DrawUpdateOAuthUIDsButton(selectedServer);
|
||||
if (selectedServer.UseOAuth2 && selectedServer.OAuthToken != null)
|
||||
if (selectedServer.UseOAuth2 && !string.IsNullOrEmpty(selectedServer.OAuthToken))
|
||||
{
|
||||
bool hasSetSecretKeysButNoUid = selectedServer.Authentications.Exists(u => u.SecretKeyIdx != -1 && string.IsNullOrEmpty(u.UID));
|
||||
if (hasSetSecretKeysButNoUid)
|
||||
|
||||
@@ -863,17 +863,17 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
|
||||
public void DrawUpdateOAuthUIDsButton(ServerStorage selectedServer)
|
||||
{
|
||||
using (ImRaii.Disabled(selectedServer.OAuthToken == null))
|
||||
using (ImRaii.Disabled(string.IsNullOrEmpty(selectedServer.OAuthToken)))
|
||||
{
|
||||
if ((_discordOAuthUIDs == null || _discordOAuthUIDs.IsCompleted)
|
||||
&& IconTextButton(FontAwesomeIcon.ArrowsSpin, "Update UIDs from Service")
|
||||
&& selectedServer.OAuthToken != null)
|
||||
&& !string.IsNullOrEmpty(selectedServer.OAuthToken))
|
||||
{
|
||||
_discordOAuthUIDs = _serverConfigurationManager.GetUIDsWithDiscordToken(selectedServer.ServerUri, selectedServer.OAuthToken);
|
||||
}
|
||||
}
|
||||
DateTime tokenExpiry = DateTime.MinValue;
|
||||
if (selectedServer.OAuthToken != null && !_oauthTokenExpiry.TryGetValue(selectedServer.OAuthToken, out tokenExpiry))
|
||||
if (!string.IsNullOrEmpty(selectedServer.OAuthToken) && !_oauthTokenExpiry.TryGetValue(selectedServer.OAuthToken, out tokenExpiry))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -889,7 +889,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
tokenExpiry = DateTime.MinValue;
|
||||
}
|
||||
}
|
||||
if (selectedServer.OAuthToken == null || tokenExpiry < DateTime.UtcNow)
|
||||
if (string.IsNullOrEmpty(selectedServer.OAuthToken) || tokenExpiry < DateTime.UtcNow)
|
||||
{
|
||||
ColorTextWrapped("You have no OAuth token or the OAuth token is expired. Please use the Service Settings to (re)link your OAuth account.", ImGuiColors.DalamudRed);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user