From 333da8a1b0ffe4e5ed005cdafdcf653da148dd24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Sat, 22 Aug 2020 22:19:43 +0300 Subject: [PATCH] Fix identity configuration --- .../MyProjectNameBlazorModule.cs | 22 ++++++++++++------- .../MyService.cs | 2 +- .../Pages/Index.razor | 15 +++++++++++++ 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorModule.cs index 5dd8da4502..c1b01e402c 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorModule.cs @@ -33,13 +33,16 @@ namespace MyCompanyName.MyProjectName.Blazor context.Services.Configure(options => { //TODO: Get from config, automatically! - options.IdentityClients.Default.Authority = "https://localhost:44305"; - options.IdentityClients.Default.GrantType = "password"; - options.IdentityClients.Default.ClientId = "MyProjectName_App"; - options.IdentityClients.Default.ClientSecret = "1q2w3e*"; - options.IdentityClients.Default.UserName = "admin"; - options.IdentityClients.Default.UserPassword = "1q2w3E*"; - options.IdentityClients.Default.Scope = "MyProjectName"; + options.IdentityClients.Default = new IdentityClientConfiguration + { + Authority = "https://localhost:44305", + GrantType = "password", + ClientId = "MyProjectName_App", + ClientSecret = "1q2w3e*", + UserName = "admin", + UserPassword = "1q2w3E*", + Scope = "MyProjectName" + }; }); } @@ -48,7 +51,10 @@ namespace MyCompanyName.MyProjectName.Blazor //TODO: Get from config, automatically! Configure(options => { - options.RemoteServices.Default.BaseUrl = "https://localhost:44305"; + options.RemoteServices.Default = new RemoteServiceConfiguration + { + BaseUrl = "https://localhost:44305" + }; }); } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyService.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyService.cs index 1c106fb378..0f8c8b8792 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyService.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyService.cs @@ -15,7 +15,7 @@ namespace MyCompanyName.MyProjectName.Blazor public async Task GetUserNameAsync() { - return "test"; + return (await _profileAppService.GetAsync()).UserName; } } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/Index.razor b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/Index.razor index e54d914390..0a99af53ce 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/Index.razor +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/Index.razor @@ -1,7 +1,22 @@ @page "/" +@inject MyProfileService MyProfileService

Hello, world!

Welcome to your new app. +

Current user name: @_userName

+ + + + +@code +{ + private string _userName = "?"; + + private async Task GetUserNameAsync() + { + _userName = await MyProfileService.GetUserNameAsync(); + } +} \ No newline at end of file