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

@ -32,8 +32,7 @@ namespace Oqtane.Services
public async Task<Alias> GetAliasAsync(int AliasId)
{
List<Alias> aliases = await http.GetJsonAsync<List<Alias>>(apiurl);
return aliases.Where(item => item.AliasId == AliasId).FirstOrDefault();
return await http.GetJsonAsync<Alias>(apiurl + "/" + AliasId.ToString());
}
public async Task AddAliasAsync(Alias alias)

View File

@ -8,6 +8,7 @@ namespace Oqtane.Services
{
Task<List<Module>> GetModulesAsync(int PageId);
Task<List<Module>> GetModulesAsync(int SiteId, string ModuleDefinitionName);
Task<Module> GetModuleAsync(int ModuleId);
Task AddModuleAsync(Module module);
Task UpdateModuleAsync(Module module);
Task DeleteModuleAsync(int ModuleId);

View File

@ -7,6 +7,7 @@ namespace Oqtane.Services
public interface IPageService
{
Task<List<Page>> GetPagesAsync(int SiteId);
Task<Page> GetPageAsync(int PageId);
Task AddPageAsync(Page page);
Task UpdatePageAsync(Page page);
Task DeletePageAsync(int PageId);

View File

@ -10,6 +10,8 @@ namespace Oqtane.Services
Task<User> GetUserAsync(int UserId);
Task<User> GetUserAsync(string Username);
Task AddUserAsync(User user);
Task UpdateUserAsync(User user);

View File

@ -39,6 +39,11 @@ namespace Oqtane.Services
return modules.ToList();
}
public async Task<Module> GetModuleAsync(int ModuleId)
{
return await http.GetJsonAsync<Module>(apiurl + "/" + ModuleId.ToString());
}
public async Task AddModuleAsync(Module module)
{
await http.PostJsonAsync(apiurl, module);

View File

@ -30,6 +30,11 @@ namespace Oqtane.Services
return pages.OrderBy(item => item.Order).ToList();
}
public async Task<Page> GetPageAsync(int PageId)
{
return await http.GetJsonAsync<Page>(apiurl + "/" + PageId.ToString());
}
public async Task AddPageAsync(Page page)
{
await http.PostJsonAsync(apiurl, page);

View File

@ -32,17 +32,7 @@ namespace Oqtane.Services
public async Task<Site> GetSiteAsync(int SiteId)
{
List<Site> sites = await http.GetJsonAsync<List<Site>>(apiurl);
Site site;
if (sites.Count == 1)
{
site = sites.FirstOrDefault();
}
else
{
site = sites.Where(item => item.SiteId == SiteId).FirstOrDefault();
}
return site;
return await http.GetJsonAsync<Site>(apiurl + "/" + SiteId.ToString());
}
public async Task AddSiteAsync(Site site)

View File

@ -35,8 +35,12 @@ namespace Oqtane.Services
public async Task<User> GetUserAsync(int UserId)
{
List<User> users = await http.GetJsonAsync<List<User>>(apiurl);
return users.Where(item => item.UserId == UserId).FirstOrDefault();
return await http.GetJsonAsync<User>(apiurl + "/" + UserId.ToString());
}
public async Task<User> GetUserAsync(string Username)
{
return await http.GetJsonAsync<User>(apiurl + "/name/" + Username);
}
public async Task AddUserAsync(User user)