Skip to content

Commit

Permalink
Enable sign-out and tasks for all tenants
Browse files Browse the repository at this point in the history
  • Loading branch information
mmacy committed Sep 18, 2019
1 parent 96a1eca commit 6c3bea4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions TaskService/Controllers/TasksController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class TasksController : ApiController
{
HasRequiredScopes(ReadPermission);

var owner = CheckClaimMatch(objectIdElement);
var owner = CheckClaimMatch(ClaimTypes.NameIdentifier);

IEnumerable<Models.Task> userTasks = db.Where(t => t.Owner == owner);
return userTasks;
Expand All @@ -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;
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions TaskWebApp/Utils/ClaimsPrincipalExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ public static string GetB2CMsalAccountId(this ClaimsPrincipal claimsPrincipal)
/// <returns>Unique object ID of the identity, or <c>null</c> if it cannot be found</returns>
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;
Expand Down

0 comments on commit 6c3bea4

Please sign in to comment.