Skip to content

Commit

Permalink
fix: check if approving atsign is a mpkam key
Browse files Browse the repository at this point in the history
  • Loading branch information
Xlin123 committed Sep 30, 2024
1 parent efa545a commit 57d0d1f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 16 deletions.
37 changes: 25 additions & 12 deletions tools/windows-installer/NoPortsInstaller/ActivateController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,31 @@ public static List<EnrollmentRecord> ListEnrollments()

return lines;
}
}

public class EnrollmentRecord(string Id, string DeviceName)
{
public string Id { get; set; } = Id;
public string DeviceName { get; set; } = DeviceName;
}
public static bool CheckIfMPKAM(string atsign)
{
var dir = Path.Combine(_controller.AtsignKeysDirectory, atsign + "_key.atKeys");
if (File.Exists(dir))
{
var fileContent = File.ReadAllText(dir);
if (fileContent.Contains("enrollmentId"))
{
return false;
}
}
return true;
}

public enum AtsignStatus
{
DNE,
NotActivated,
Activated
public class EnrollmentRecord(string Id, string DeviceName)
{
public string Id { get; set; } = Id;
public string DeviceName { get; set; } = DeviceName;
}

public enum AtsignStatus
{
DNE,
NotActivated,
Activated
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@
<Label Content="Enter atSign:" HorizontalAlignment="Left" Height="27" VerticalAlignment="Top" Width="199" Margin="168,75,0,0" FontSize="11"/>
<ComboBox x:Name="AtsignCombo" HorizontalAlignment="Left" Height="26" Margin="177,107,0,0" VerticalAlignment="Top" Width="211" IsEditable="True" Initialized="AtsignCombo_Initialized">
</ComboBox>
<Label x:Name="MPKAMCheckLabel" Content="" HorizontalAlignment="Left" Margin="177,149,0,0" VerticalAlignment="Top" Width="224"/>
</Grid>
</Page>
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,21 @@ private void Next_Click(object sender, RoutedEventArgs e)
{
if (AtsignCombo.Text != "")
{
_controller.DeviceAtsign = _controller.NormalizeAtsign(AtsignCombo.Text);
_controller.Pages.Add(new Approve());
_controller.Pages.Add(new FinishGeneratingKeys());
_controller.NextPage();
try
{
var atsign = _controller.NormalizeAtsign(AtsignCombo.Text);
if (ActivateController.CheckIfMPKAM(atsign))
{
_controller.DeviceAtsign = _controller.NormalizeAtsign(AtsignCombo.Text);
_controller.Pages.Add(new Approve());
_controller.Pages.Add(new FinishGeneratingKeys());
_controller.NextPage();
}
}
catch
{
_controller.LoadError(new Exception("Failed to find MPKAM Keys for the given atsign"));
}
}
}
}
Expand Down

0 comments on commit 57d0d1f

Please sign in to comment.