Added inline documentation + fixed small bugs
This commit is contained in:
@@ -8,9 +8,18 @@ public interface IAuthLogic {
|
||||
|
||||
Task<LogicResult<SingleValueResult<string>>> Register(UserRegister register);
|
||||
|
||||
/// <summary>
|
||||
/// Reassures that the user has a valid refresh token and generates a new access token
|
||||
/// </summary>
|
||||
/// <returns>The newly generated access token</returns>
|
||||
Task<LogicResult<SingleValueResult<string>>> Authenticate();
|
||||
|
||||
Task<LogicResult> Logout();
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the user account that called the endpoint if the provided password is correct
|
||||
/// </summary>
|
||||
/// <param name="validation">The password od the user</param>
|
||||
/// <returns></returns>
|
||||
Task<LogicResult> Delete(UserPasswordValidation validation);
|
||||
}
|
||||
@@ -1,5 +1,10 @@
|
||||
namespace HopFrame.Api.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Useful for endpoints that only return a single int or string
|
||||
/// </summary>
|
||||
/// <param name="value">The value of the result</param>
|
||||
/// <typeparam name="TValue">The type of the result</typeparam>
|
||||
public struct SingleValueResult<TValue>(TValue value) {
|
||||
public TValue Value { get; set; } = value;
|
||||
|
||||
|
||||
@@ -19,5 +19,5 @@ public interface IPermissionRepository {
|
||||
|
||||
Task RemovePermission(IPermissionOwner owner, string permission);
|
||||
|
||||
public Task<IList<string>> GetFullPermissions(IPermissionOwner owner);
|
||||
Task<IList<string>> GetFullPermissions(IPermissionOwner owner);
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using HopFrame.Database.Models;
|
||||
namespace HopFrame.Database.Repositories;
|
||||
|
||||
public interface ITokenRepository {
|
||||
public Task<Token> GetToken(string content);
|
||||
public Task<Token> CreateToken(int type, User owner);
|
||||
public Task DeleteUserTokens(User owner);
|
||||
Task<Token> GetToken(string content);
|
||||
Task<Token> CreateToken(int type, User owner);
|
||||
Task DeleteUserTokens(User owner);
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace HopFrame.Web.Admin.Models;
|
||||
|
||||
public sealed class AdminPageProperty {
|
||||
|
||||
@@ -7,6 +7,9 @@ using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace HopFrame.Web;
|
||||
|
||||
/// <summary>
|
||||
/// Assures that the user stays logged in even if the access token is expired
|
||||
/// </summary>
|
||||
public sealed class AuthMiddleware(IAuthService auth, IPermissionRepository perms) : IMiddleware {
|
||||
public async Task InvokeAsync(HttpContext context, RequestDelegate next) {
|
||||
var loggedIn = await auth.IsLoggedIn();
|
||||
@@ -14,7 +17,7 @@ public sealed class AuthMiddleware(IAuthService auth, IPermissionRepository perm
|
||||
if (!loggedIn) {
|
||||
var token = await auth.RefreshLogin();
|
||||
if (token is null) {
|
||||
await next.Invoke(context);
|
||||
next?.Invoke(context);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ using HopFrame.Web.Repositories;
|
||||
|
||||
namespace HopFrame.Web;
|
||||
|
||||
public class HopAdminContext : AdminPagesContext {
|
||||
internal class HopAdminContext : AdminPagesContext {
|
||||
|
||||
public AdminPage<User> Users { get; set; }
|
||||
public AdminPage<PermissionGroup> Groups { get; set; }
|
||||
|
||||
@@ -5,11 +5,14 @@
|
||||
@using BlazorStrap
|
||||
@using HopFrame.Web.Pages.Administration.Layout
|
||||
@using BlazorStrap.V5
|
||||
@using HopFrame.Security
|
||||
@using HopFrame.Web.Admin.Providers
|
||||
@using HopFrame.Web.Components
|
||||
@using Microsoft.AspNetCore.Components.Web
|
||||
@layout AdminLayout
|
||||
|
||||
<AuthorizedView Permission="@AdminPermissions.IsAdmin" RedirectIfUnauthorized="/administration/login" />
|
||||
|
||||
<PageTitle>Admin Dashboard</PageTitle>
|
||||
|
||||
<BSContainer>
|
||||
|
||||
@@ -30,13 +30,12 @@
|
||||
}
|
||||
</BSNav>
|
||||
|
||||
<span style="margin-left: auto; line-height: 100%; color: white">
|
||||
<span style="margin-left: auto; line-height: 100%; color: white; margin-right: 10px">
|
||||
logged in as @Context?.User.Username
|
||||
</span>
|
||||
<BSButton DataId="logout" Size="Size.ExtraSmall" OnClick="Logout" Color="BSColor.Dark">
|
||||
<BSButton DataId="logout" Size="Size.ExtraSmall" OnClick="Logout" Color="BSColor.Dark" style="display: grid; align-items: center">
|
||||
<HopIconDisplay Type="HopIconDisplay.HopIcon.Logout"/>
|
||||
</BSButton>
|
||||
<BSTooltip Placement="Placement.Bottom" Target="logout" ContentAlwaysRendered="false">logout</BSTooltip>
|
||||
</Content>
|
||||
</BSCollapse>
|
||||
</BSContainer>
|
||||
|
||||
Reference in New Issue
Block a user