-
Notifications
You must be signed in to change notification settings - Fork 1
/
CredentialsHelper.cs
39 lines (33 loc) · 1.12 KB
/
CredentialsHelper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using SuchByte.MacroDeck.Logging;
using SuchByte.MacroDeck.Plugins;
using System;
using System.Collections.Generic;
using System.Linq;
namespace SuchByte.PiHolePlugin;
internal static class CredentialsHelper
{
public static void UpdateToken(string token)
{
Dictionary<string, string> credentials = new Dictionary<string, string>
{
["token"] = token
};
PluginCredentials.SetCredentials(Main.Instance, credentials);
}
public static string GetToken()
{
try
{
List<Dictionary<string, string>> credentialsList = PluginCredentials.GetPluginCredentials(Main.Instance);
if (credentialsList == null || credentialsList.Count == 0) return null;
Dictionary<string, string> credentials = credentialsList.FirstOrDefault();
if (credentials == null) return "";
return credentials["token"];
}
catch (Exception ex)
{
MacroDeckLogger.Error(Main.Instance, $"Error while getting credentials: { ex.Message + Environment.NewLine + ex.StackTrace }");
}
return "";
}
}