From 6c3bea440e10bd43896ab926ab4e6bc603250c61 Mon Sep 17 00:00:00 2001 From: Marsh Macy Date: Wed, 18 Sep 2019 11:28:48 -0700 Subject: [PATCH] Enable sign-out and tasks for all tenants --- TaskService/Controllers/TasksController.cs | 6 +++--- TaskWebApp/Utils/ClaimsPrincipalExtension.cs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/TaskService/Controllers/TasksController.cs b/TaskService/Controllers/TasksController.cs index b18d1ba..45470b2 100644 --- a/TaskService/Controllers/TasksController.cs +++ b/TaskService/Controllers/TasksController.cs @@ -33,7 +33,7 @@ public class TasksController : ApiController { HasRequiredScopes(ReadPermission); - var owner = CheckClaimMatch(objectIdElement); + var owner = CheckClaimMatch(ClaimTypes.NameIdentifier); IEnumerable userTasks = db.Where(t => t.Owner == owner); return userTasks; @@ -49,7 +49,7 @@ public void Post(Models.Task task) if (String.IsNullOrEmpty(task.Text)) throw new WebException("Please provide a task description"); - var owner = CheckClaimMatch(objectIdElement); + var owner = CheckClaimMatch(ClaimTypes.NameIdentifier); task.Id = taskId++; task.Owner = owner; @@ -65,7 +65,7 @@ public void Delete(int id) { HasRequiredScopes(WritePermission); - var owner = CheckClaimMatch(objectIdElement); + var owner = CheckClaimMatch(ClaimTypes.NameIdentifier); Models.Task task = db.Where(t => t.Owner.Equals(owner) && t.Id.Equals(id)).FirstOrDefault(); db.Remove(task); diff --git a/TaskWebApp/Utils/ClaimsPrincipalExtension.cs b/TaskWebApp/Utils/ClaimsPrincipalExtension.cs index 9090a4c..7e22f50 100644 --- a/TaskWebApp/Utils/ClaimsPrincipalExtension.cs +++ b/TaskWebApp/Utils/ClaimsPrincipalExtension.cs @@ -54,11 +54,11 @@ public static string GetB2CMsalAccountId(this ClaimsPrincipal claimsPrincipal) /// Unique object ID of the identity, or null if it cannot be found public static string GetObjectId(this ClaimsPrincipal claimsPrincipal) { - var objIdclaim = claimsPrincipal.FindFirst(ClaimConstants.ObjectId); + var objIdclaim = claimsPrincipal.FindFirst(ClaimTypes.NameIdentifier); if (objIdclaim == null) { - objIdclaim = claimsPrincipal.FindFirst("oid"); + objIdclaim = claimsPrincipal.FindFirst("sub"); } return objIdclaim != null ? objIdclaim.Value : string.Empty;