Refactoring authentication to support server-side Blazor using a seamless login flow.

This commit is contained in:
Shaun Walker
2019-07-15 08:30:03 -04:00
parent f3c823e667
commit ce069ed45b
28 changed files with 307 additions and 86 deletions

View File

@ -13,17 +13,18 @@ namespace Oqtane.Shared
this.jsRuntime = jsRuntime;
}
public Task<string> SetCookie(string name, string value, int days)
public Task SetCookie(string name, string value, int days)
{
try
{
return jsRuntime.InvokeAsync<string>(
jsRuntime.InvokeAsync<string>(
"interop.setCookie",
name, value, days);
return Task.CompletedTask;
}
catch
{
return Task.FromResult(string.Empty);
return Task.CompletedTask;
}
}
@ -41,18 +42,48 @@ namespace Oqtane.Shared
}
}
public Task<string> AddCSS(string filename)
public Task AddCSS(string filename)
{
try
{
jsRuntime.InvokeAsync<string>(
"interop.addCSS",
filename);
return Task.CompletedTask;
}
catch
{
return Task.CompletedTask;
}
}
public Task<string> GetElementByName(string name)
{
try
{
return jsRuntime.InvokeAsync<string>(
"interop.addCSS",
filename);
"interop.getElementByName",
name);
}
catch
{
return Task.FromResult(string.Empty);
}
}
public Task SubmitForm(string path, object fields)
{
try
{
jsRuntime.InvokeAsync<string>(
"interop.submitForm",
path, fields);
return Task.CompletedTask;
}
catch
{
return Task.CompletedTask;
}
}
}
}

View File

@ -127,7 +127,7 @@ private async Task Refresh()
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
if (authState.User.Identity.IsAuthenticated)
{
user = await UserService.GetCurrentUserAsync();
user = await UserService.GetUserAsync(authState.User.Identity.Name);
}
}
else

View File

@ -25,7 +25,14 @@ namespace Oqtane.Shared
string url = pagestate.Alias.Path + "/" + path;
if (reload)
{
url += "?reload=true";
if (url.Contains("?"))
{
url += "&reload=true";
}
else
{
url += "?reload=true";
}
}
return url;
}