mirror of
https://github.com/hmaxnl/SharpRSS.git
synced 2025-01-18 12:54:20 +01:00
Preparing db models for authentication implementation
This commit is contained in:
parent
e8572915de
commit
c4ae8ab195
|
@ -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<AuthenticationState> GetAuthenticationStateAsync()
|
||||
{
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />
|
||||
<PackageReference Include="MudBlazor" Version="6.20.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -22,4 +22,9 @@ public class AuthService
|
|||
{
|
||||
return Result.Failed("NotImplemented");
|
||||
}
|
||||
|
||||
public async Task<Result> ValidateAuthenticationStateAsync(string id)
|
||||
{
|
||||
return Result.Failed("NotImplemented");
|
||||
}
|
||||
}
|
10
SharpRSS.Data/Domains/Auth/AuthenticationStateModel.cs
Normal file
10
SharpRSS.Data/Domains/Auth/AuthenticationStateModel.cs
Normal file
|
@ -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; }
|
||||
}
|
8
SharpRSS.Data/Domains/Auth/Identity/RoleModel.cs
Normal file
8
SharpRSS.Data/Domains/Auth/Identity/RoleModel.cs
Normal file
|
@ -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;
|
||||
}
|
15
SharpRSS.Data/Domains/Auth/Identity/UserModel.cs
Normal file
15
SharpRSS.Data/Domains/Auth/Identity/UserModel.cs
Normal file
|
@ -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; }
|
||||
}
|
10
SharpRSS.Data/Domains/Auth/RegisterModel.cs
Normal file
10
SharpRSS.Data/Domains/Auth/RegisterModel.cs
Normal file
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user