fixes for running on WebAssembly

This commit is contained in:
Shaun Walker 2021-05-13 07:58:57 -04:00
parent fe3b42feed
commit 943adec3a0
4 changed files with 17 additions and 9 deletions

View File

@ -120,7 +120,7 @@ namespace Oqtane.Client
var assemblies = AppDomain.CurrentDomain.GetAssemblies().Select(a => a.GetName().Name).ToList();
// get assemblies from server and load into client app domain
var zip = await http.GetByteArrayAsync($"/~/api/Installation/load");
var zip = await http.GetByteArrayAsync($"/api/Installation/load");
// asemblies and debug symbols are packaged in a zip file
using (ZipArchive archive = new ZipArchive(new MemoryStream(zip)))

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Net.Http;
using System.Net.Http.Json;
using System.Security.Claims;
@ -28,12 +28,12 @@ namespace Oqtane.Providers
public override async Task<AuthenticationState> GetAuthenticationStateAsync()
{
// get HttpClient lazily from IServiceProvider as you cannot use standard dependency injection due to the AuthenticationStateProvider being initialized prior to NavigationManager ( https://github.com/aspnet/AspNetCore/issues/11867 )
var http = _serviceProvider.GetRequiredService<HttpClient>();
string apiurl = "/~/api/User/authenticate";
User user = await http.GetFromJsonAsync<User>(apiurl);
ClaimsIdentity identity = new ClaimsIdentity();
// get HttpClient lazily from IServiceProvider as you cannot use standard dependency injection due to the AuthenticationStateProvider being initialized prior to NavigationManager(https://github.com/aspnet/AspNetCore/issues/11867 )
var http = _serviceProvider.GetRequiredService<HttpClient>();
string apiurl = "/api/User/authenticate";
User user = await http.GetFromJsonAsync<User>(apiurl);
if (user.IsAuthenticated)
{
identity = new ClaimsIdentity("Identity.Application");
@ -44,6 +44,7 @@ namespace Oqtane.Providers
identity.AddClaim(new Claim(ClaimTypes.Role, role));
}
}
return new AuthenticationState(new ClaimsPrincipal(identity));
}

View File

@ -444,7 +444,7 @@ namespace Oqtane.Controllers
return user;
}
// GET api/<controller>/current
// GET api/<controller>/authenticate
[HttpGet("authenticate")]
public User Authenticate()
{

View File

@ -22,7 +22,14 @@
<body>
@(Html.AntiForgeryToken())
<app>
<component type="typeof(Oqtane.App)" render-mode="ServerPrerendered" />
@if (Configuration.GetSection("Runtime").Value == "WebAssembly")
{
<component type="typeof(Oqtane.App)" render-mode="Server" />
}
else
{
<component type="typeof(Oqtane.App)" render-mode="ServerPrerendered" />
}
</app>
<div id="blazor-error-ui">