diff --git a/SharpRSS.Blazor/Auth/SRSSAuthenticationStateProvider.cs b/SharpRSS.Blazor/Auth/SRSSAuthenticationStateProvider.cs index 538c432..da60a16 100644 --- a/SharpRSS.Blazor/Auth/SRSSAuthenticationStateProvider.cs +++ b/SharpRSS.Blazor/Auth/SRSSAuthenticationStateProvider.cs @@ -1,3 +1,4 @@ +using Blazored.LocalStorage; using DotBased.Logging; using Microsoft.AspNetCore.Components.Authorization; using SharpRSS.Business.Services; @@ -7,7 +8,7 @@ namespace SharpRSS.Blazor.Auth; public class SRSSAuthenticationStateProvider : AuthenticationStateProvider { - public SRSSAuthenticationStateProvider(IHttpContextAccessor contextAccessor, AuthService authService) + public SRSSAuthenticationStateProvider(IHttpContextAccessor contextAccessor, AuthService authService, ILocalStorageService localStorageService) { _logger = LogService.RegisterLogger(typeof(SRSSAuthenticationStateProvider)); if (contextAccessor.HttpContext != null) @@ -19,11 +20,20 @@ public class SRSSAuthenticationStateProvider : AuthenticationStateProvider throw ex; } _authService = authService; + _localStorageService = localStorageService; } - + + /* + * Services + */ private readonly ILogger _logger; private readonly HttpContext _httpContext; private readonly AuthService _authService; + private readonly ILocalStorageService _localStorageService; + /* + * Consts + */ + private const string AuthIdName = "srss_auth_id"; public override Task GetAuthenticationStateAsync() { diff --git a/SharpRSS.Blazor/Program.cs b/SharpRSS.Blazor/Program.cs index 1c2f50a..4360b05 100644 --- a/SharpRSS.Blazor/Program.cs +++ b/SharpRSS.Blazor/Program.cs @@ -1,3 +1,4 @@ +using Blazored.LocalStorage; using Microsoft.EntityFrameworkCore; using MudBlazor.Services; using SharpRSS.Blazor.Components; @@ -7,6 +8,7 @@ using SharpRSS.Data; var builder = WebApplication.CreateBuilder(args); builder.UseSRSS(); +builder.Services.AddBlazoredLocalStorage(); // Add services to the container. builder.Services.AddRazorComponents() diff --git a/SharpRSS.Blazor/SharpRSS.Blazor.csproj b/SharpRSS.Blazor/SharpRSS.Blazor.csproj index 392cb44..51196ae 100644 --- a/SharpRSS.Blazor/SharpRSS.Blazor.csproj +++ b/SharpRSS.Blazor/SharpRSS.Blazor.csproj @@ -12,6 +12,7 @@ + diff --git a/SharpRSS.Business/Services/AuthService.cs b/SharpRSS.Business/Services/AuthService.cs index be21975..f85bd99 100644 --- a/SharpRSS.Business/Services/AuthService.cs +++ b/SharpRSS.Business/Services/AuthService.cs @@ -22,4 +22,9 @@ public class AuthService { return Result.Failed("NotImplemented"); } + + public async Task ValidateAuthenticationStateAsync(string id) + { + return Result.Failed("NotImplemented"); + } } \ No newline at end of file diff --git a/SharpRSS.Data/Domains/Auth/AuthenticationStateModel.cs b/SharpRSS.Data/Domains/Auth/AuthenticationStateModel.cs new file mode 100644 index 0000000..4dbb23f --- /dev/null +++ b/SharpRSS.Data/Domains/Auth/AuthenticationStateModel.cs @@ -0,0 +1,10 @@ +namespace SharpRSS.Data.Domains.Auth; + +public class AuthenticationStateModel +{ + public string Id { get; set; } = Guid.NewGuid().ToString(); + public DateTime Created { get; set; } = DateTime.Now; + public DateTime LastHit { get; set; } + public string UserIdReference { get; set; } = string.Empty; + public bool LoggedIn { get; set; } +} \ No newline at end of file diff --git a/SharpRSS.Data/Domains/Auth/Identity/RoleModel.cs b/SharpRSS.Data/Domains/Auth/Identity/RoleModel.cs new file mode 100644 index 0000000..b33e675 --- /dev/null +++ b/SharpRSS.Data/Domains/Auth/Identity/RoleModel.cs @@ -0,0 +1,8 @@ +namespace SharpRSS.Data.Domains.Auth.Identity; + +public class RoleModel +{ + public string UserId { get; set; } = string.Empty; + public string RoleId { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; +} \ No newline at end of file diff --git a/SharpRSS.Data/Domains/Auth/Identity/UserModel.cs b/SharpRSS.Data/Domains/Auth/Identity/UserModel.cs new file mode 100644 index 0000000..81f9a06 --- /dev/null +++ b/SharpRSS.Data/Domains/Auth/Identity/UserModel.cs @@ -0,0 +1,15 @@ +namespace SharpRSS.Data.Domains.Auth.Identity; + +public class UserModel +{ + public string Id { get; set; } = Guid.NewGuid().ToString(); + public string Email { get; set; } = string.Empty; + public string UserName { get; set; } = string.Empty; + public string PasswordHash { get; set; } = string.Empty; + public string Name { get; set; } = string.Empty; + public string FamilyName { get; set; } = string.Empty; + public DateTime CreatedDate { get; set; } = DateTime.Now; + public DateTime LastLogin { get; set; } + public bool IsEnabled { get; set; } + public bool IsAdmin { get; set; } +} \ No newline at end of file diff --git a/SharpRSS.Data/Domains/Auth/RegisterModel.cs b/SharpRSS.Data/Domains/Auth/RegisterModel.cs new file mode 100644 index 0000000..6113bbc --- /dev/null +++ b/SharpRSS.Data/Domains/Auth/RegisterModel.cs @@ -0,0 +1,10 @@ +namespace SharpRSS.Data.Domains.Auth; + +public class RegisterModel +{ + public string UserName { get; set; } = string.Empty; + public string Password { get; set; } = string.Empty; + public string Name { get; set; } = string.Empty; + public string FamilyName { get; set; } = string.Empty; + public string Email { get; set; } = string.Empty; +} \ No newline at end of file