Last active
February 9, 2021 16:05
-
-
Save OnSive/3a5b4bf314f8e3e1758213fd7b6bb134 to your computer and use it in GitHub Desktop.
[GetUserAsync with IdentityServer Fix] Let you use the UserManager.GetUserAsync function again #Blazor #IdentityServer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Add following code to the server Startup.cs file */ | |
| public void ConfigureServices(IServiceCollection services) | |
| { | |
| // ... | |
| services.AddIdentityServer() | |
| .AddApiAuthorization<ApplicationUser, ApplicationDbContext>(); | |
| // Add this configuration of the IdentityServer options | |
| // https://github.com/dotnet/AspNetCore.Docs/issues/17517#issuecomment-605993247 | |
| services.Configure<IdentityOptions>(options => options.ClaimsIdentity.UserIdClaimType = ClaimTypes.NameIdentifier); | |
| } | |
| // GetUserAsync works now within a controller | |
| var user = await _userManager.GetUserAsync(User); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment