Skip to content

Commit c5556f4

Browse files
authored
Merge pull request #60 from mmacy/fix-logout
Enable sign-out and tasks for all tenants
2 parents 96a1eca + 6c3bea4 commit c5556f4

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

TaskService/Controllers/TasksController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class TasksController : ApiController
3333
{
3434
HasRequiredScopes(ReadPermission);
3535

36-
var owner = CheckClaimMatch(objectIdElement);
36+
var owner = CheckClaimMatch(ClaimTypes.NameIdentifier);
3737

3838
IEnumerable<Models.Task> userTasks = db.Where(t => t.Owner == owner);
3939
return userTasks;
@@ -49,7 +49,7 @@ public void Post(Models.Task task)
4949
if (String.IsNullOrEmpty(task.Text))
5050
throw new WebException("Please provide a task description");
5151

52-
var owner = CheckClaimMatch(objectIdElement);
52+
var owner = CheckClaimMatch(ClaimTypes.NameIdentifier);
5353

5454
task.Id = taskId++;
5555
task.Owner = owner;
@@ -65,7 +65,7 @@ public void Delete(int id)
6565
{
6666
HasRequiredScopes(WritePermission);
6767

68-
var owner = CheckClaimMatch(objectIdElement);
68+
var owner = CheckClaimMatch(ClaimTypes.NameIdentifier);
6969

7070
Models.Task task = db.Where(t => t.Owner.Equals(owner) && t.Id.Equals(id)).FirstOrDefault();
7171
db.Remove(task);

TaskWebApp/Utils/ClaimsPrincipalExtension.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ public static string GetB2CMsalAccountId(this ClaimsPrincipal claimsPrincipal)
5454
/// <returns>Unique object ID of the identity, or <c>null</c> if it cannot be found</returns>
5555
public static string GetObjectId(this ClaimsPrincipal claimsPrincipal)
5656
{
57-
var objIdclaim = claimsPrincipal.FindFirst(ClaimConstants.ObjectId);
57+
var objIdclaim = claimsPrincipal.FindFirst(ClaimTypes.NameIdentifier);
5858

5959
if (objIdclaim == null)
6060
{
61-
objIdclaim = claimsPrincipal.FindFirst("oid");
61+
objIdclaim = claimsPrincipal.FindFirst("sub");
6262
}
6363

6464
return objIdclaim != null ? objIdclaim.Value : string.Empty;

0 commit comments

Comments
 (0)