Skip to content

Commit

Permalink
💾 Feat(Dashboard): Now you can unauthorize other devices.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dynesshely committed Mar 5, 2024
1 parent 57f3146 commit 54be359
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions KitX Dashboard/Managers/SecurityManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Security.Cryptography;
using System.Text;
using Common.BasicHelper.Utils.Extensions;
using DynamicData;
using KitX.Dashboard.Configuration;
using KitX.Dashboard.Network.DevicesNetwork;
using KitX.Shared.CSharp.Device;
Expand Down Expand Up @@ -75,6 +76,19 @@ public SecurityManager AddDeviceKey(DeviceKey deviceKey)
return this;
}

public SecurityManager RemoveDeviceKey(DeviceInfo deviceInfo)
{
SecurityConfig.DeviceKeys.RemoveMany(
SecurityConfig.DeviceKeys.Where(
x => x.Device.IsSameDevice(deviceInfo.Device)
)
);

SecurityConfig.Save(SecurityConfig.ConfigFileLocation!);

return this;
}

public static bool IsDeviceAuthorized(DeviceLocator device) => SecurityConfig.DeviceKeys.Any(x => x.Device.IsSameDevice(device));

public string? EncryptString(string data)
Expand Down
2 changes: 2 additions & 0 deletions KitX Dashboard/Models/DeviceCase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ public override void InitCommands()
return;
}
SecurityManager.Instance.RemoveDeviceKey(info);
},
this.WhenAnyValue(x => x.IsAuthorized)
);
Expand Down

0 comments on commit 54be359

Please sign in to comment.