Skip to content

Commit

Permalink
fixed problems in previous revision
Browse files Browse the repository at this point in the history
  • Loading branch information
mattebit committed Mar 1, 2024
1 parent b7414ee commit 2c3a501
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def test_trust_mark_status_endpoint(self):
res = c.post(
url,
data={
"id": self.rp_assigned_profile.profile.profile_id,
"trust_mark_id": self.rp_assigned_profile.profile.profile_id,
"sub": self.rp_assigned_profile.descendant.sub,
},
)
Expand All @@ -278,7 +278,7 @@ def test_trust_mark_status_endpoint(self):
res = c.get(
url,
data={
"id": self.rp_assigned_profile.profile.profile_id,
"trust_mark_id": self.rp_assigned_profile.profile.profile_id,
"sub": self.rp_assigned_profile.descendant.sub,
}
)
Expand Down Expand Up @@ -313,7 +313,7 @@ def test_trust_mark_status_endpoint(self):
res = c.get(
url,
data={
"id": self.rp_assigned_profile.profile.profile_id,
"trust_mark_id": self.rp_assigned_profile.profile.profile_id,
},
)
self.assertTrue(res.status_code == 200)
Expand Down
15 changes: 9 additions & 6 deletions spid_cie_oidc/authority/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,19 +217,22 @@ def trust_mark_status(request):
failed_data = {"active": False}

sub = request.POST.get("sub") or request.GET.get("sub", None)
_id = request.POST.get("trust_mark_id) or request.GET.get("trust_mark_id", None)
if not request.GET or request.POST:
return JsonResponse({"error": "Method not allowed"}, status=400)
_id = request.POST.get("trust_mark_id") or request.GET.get("trust_mark_id", None)
trust_mark = request.POST.get("trust_mark") or request.GET.get("trust_mark", None)

if request.method not in ['GET', 'POST']:
return JsonResponse({"error": "Method not allowed"}, status=400)

if request.POST.get("trust_mark", ""):
if trust_mark:
try:
unpad_jwt_head(params["trust_mark"])
payload = unpad_jwt_payload(params["trust_mark"])
unpad_jwt_head(trust_mark)
payload = unpad_jwt_payload(trust_mark)
sub = payload.get("sub", "")
_id = payload.get("id", "")
except Exception:
return JsonResponse(failed_data)
elif sub and _id:
pass
else:
return JsonResponse(failed_data)

Expand Down

0 comments on commit 2c3a501

Please sign in to comment.