Skip to content

Commit

Permalink
add DisplayName to dev apps (#409)
Browse files Browse the repository at this point in the history
* set name claim in web api

* reverting change for now and using DisplayName instead

* fix test
  • Loading branch information
jennyf19 authored Aug 5, 2020
1 parent d23ca81 commit 3bf0cea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Identity.Web;
using System.Collections.Generic;
using System.Linq;
using TodoListService.Models;
Expand Down Expand Up @@ -36,7 +37,7 @@ public TodoListController(IHttpContextAccessor contextAccessor)
[Authorize(Policy = "ReadScope")]
public IEnumerable<Todo> Get()
{
string owner = User.Identity.Name;
string owner = User.GetDisplayName();
return TodoStore.Values.Where(x => x.Owner == owner);
}

Expand Down Expand Up @@ -85,4 +86,4 @@ public IActionResult Patch(int id, [FromBody] Todo todo)
return Ok(todo);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public TodoListController(
public async Task<IEnumerable<Todo>> GetAsync()
{
HttpContext.VerifyUserHasAnyAcceptedScope(scopeRequiredByApi);
string owner = User.Identity.Name;
string owner = User.GetDisplayName();
// Below is for testing multi-tenants
// string token1 = await _tokenAcquisition.GetAccessTokenForUserAsync(new string[] { "user.read" }, "7f58f645-c190-4ce5-9de4-e2b7acd2a6ab").ConfigureAwait(false);
// string token2 = await _tokenAcquisition.GetAccessTokenForUserAsync(new string[] { "user.read" }, "3ebb7dbb-24a5-4083-b60c-5a5977aabf3d").ConfigureAwait(false);
Expand Down

0 comments on commit 3bf0cea

Please sign in to comment.