Skip to content

Commit

Permalink
code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
damienbod committed Mar 9, 2024
1 parent aad89ce commit 9698efc
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 34 deletions.
2 changes: 1 addition & 1 deletion EmployeeUnlockDoor/Pages/Error.cshtml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Diagnostics;

namespace EmployeeUnlockDoor.Pages;

Expand Down
10 changes: 5 additions & 5 deletions EmployeeUnlockDoor/Pages/UnlockDoor/UnlockDoor.cshtml.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using Microsoft.AspNetCore.Mvc;
using System.Security.Claims;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Caching.Distributed;
using VerifierInsuranceCompany.Services;
using System.Security.Claims;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;

namespace EmployeeUnlockDoor.Pages.UnlockDoor;

Expand Down Expand Up @@ -49,7 +49,7 @@ public async Task<IActionResult> OnPostAsync()
new Claim("Mail", credentialData!.Employee.Mail, ClaimValueTypes.String, "damienbodsharepoint"),
new Claim("Surname", credentialData!.Employee.Surname, ClaimValueTypes.String, "damienbodsharepoint"),
new Claim("Photo", credentialData!.Employee.Photo, ClaimValueTypes.String, "damienbodsharepoint"),
new Claim("DoorCode", credentialData!.DoorCode, ClaimValueTypes.String, "damienbodsharepoint"),
new Claim("DoorCode", credentialData!.DoorCode, ClaimValueTypes.String, "damienbodsharepoint"),
};

var userIdentity = new ClaimsIdentity(claims, "entraemployee");
Expand Down
6 changes: 2 additions & 4 deletions EmployeeUnlockDoor/Pages/UnlockDoor/Unlocked.cshtml.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.AspNetCore.Authentication;
using static System.Runtime.InteropServices.JavaScript.JSType;

namespace EmployeeUnlockDoor.Pages.UnlockDoor;

Expand Down
1 change: 0 additions & 1 deletion EmployeeUnlockDoor/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using VerifierInsuranceCompany;

namespace EmployeeUnlockDoor;
Expand Down
2 changes: 1 addition & 1 deletion EmployeeUnlockDoor/Services/CredentialSettings.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Microsoft.Identity.Web;
using System.Security.Cryptography.X509Certificates;
using Microsoft.Identity.Web;

namespace VerifierInsuranceCompany;

Expand Down
1 change: 0 additions & 1 deletion EmployeeUnlockDoor/Services/VerifierCallbackResponse.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using EmployeeUnlockDoor.Services;

namespace VerifierInsuranceCompany.Services;

Expand Down
21 changes: 12 additions & 9 deletions EmployeeUnlockDoor/Services/VerifierController.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
using System.Globalization;
using System.Net;
using System.Net.Http.Headers;
using Microsoft.Extensions.Options;
using VerifierInsuranceCompany.Services;
using System.Text.Json;
using System.Globalization;
using Microsoft.Extensions.Caching.Distributed;
using EmployeeUnlockDoor.Services;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Options;
using VerifierInsuranceCompany.Services;

namespace VerifierInsuranceCompany;

Expand Down Expand Up @@ -98,7 +98,7 @@ public async Task<ActionResult> PresentationCallback()

try
{
if (verifierCallbackResponse != null && verifierCallbackResponse.RequestStatus == VerifierConst.RequestRetrieved)
if (verifierCallbackResponse != null && verifierCallbackResponse.RequestStatus == VerifierConst.RequestRetrieved)
{
var cacheData = new CacheData
{
Expand Down Expand Up @@ -150,7 +150,7 @@ private static void ParseClaimsData(VerifiedCredentialsData verifiedCredentialsD
else // "DoorCode"
{
var data = verifiedCredentialsData!.Claims.Deserialize<DoorCodeClaims>();
if(data!.DoorCode != null)
if (data!.DoorCode != null)
cacheData.DoorCode = data.DoorCode;
}
}
Expand All @@ -170,8 +170,11 @@ public ActionResult PresentationResponse()
if (data != null)
{
Debug.WriteLine("check if there was a response yet: " + data);
return new ContentResult { ContentType = "application/json",
Content = JsonSerializer.Serialize(data) };
return new ContentResult
{
ContentType = "application/json",
Content = JsonSerializer.Serialize(data)
};
}

return Ok();
Expand Down
2 changes: 1 addition & 1 deletion EmployeeUnlockDoor/ValidateUserAndDoorCodeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class ValidateUserAndDoorCodeService

// simi check, only accept requests for "2023" and any upn
// This code be updated once a month
if(doorCode == "2023")
if (doorCode == "2023")
return (true, string.Empty);

return (false, "Error, data code is incorrect, code is '2023'");
Expand Down
2 changes: 1 addition & 1 deletion IssueUnlockDoor/Pages/Error.cshtml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Diagnostics;

namespace IssueUnlockDoor.Pages;

Expand Down
2 changes: 0 additions & 2 deletions IssueUnlockDoor/SecurityHeadersDefinitions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Microsoft.AspNetCore.Builder;

namespace IssueUnlockDoor;

public static class SecurityHeadersDefinitions
Expand Down
2 changes: 1 addition & 1 deletion IssueUnlockDoor/Services/CredentialSettings.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Microsoft.Identity.Web;
using System.Security.Cryptography.X509Certificates;
using Microsoft.Identity.Web;

namespace IssueUnlockDoor;

Expand Down
10 changes: 5 additions & 5 deletions IssueUnlockDoor/Services/IssuerController.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using System.Net;
using System.Diagnostics;
using System.Globalization;
using System.Net;
using System.Net.Http.Headers;
using System.Text.Json;
using IssueUnlockDoor.Services;
using Microsoft.AspNetCore.Authorization;
using System.Text.Json;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Distributed;
using System.Globalization;
using Microsoft.Extensions.Options;

namespace IssueUnlockDoor;

Expand Down
2 changes: 0 additions & 2 deletions IssueUnlockDoor/Services/IssuerService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Globalization;
using System.Security.Cryptography;
using IssueUnlockDoor.Services;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options;
Expand Down

0 comments on commit 9698efc

Please sign in to comment.