From 0aa28d9764888ad99e151b3c42669bcf0b9c257d Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Fri, 5 Jan 2024 11:04:43 +0100 Subject: [PATCH 1/2] Fixed service renewal check to allow admins to access the service even if it is expired --- Moonlight/Shared/Views/Service/Index.razor | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Moonlight/Shared/Views/Service/Index.razor b/Moonlight/Shared/Views/Service/Index.razor index 47e0d4c..a1c2db6 100644 --- a/Moonlight/Shared/Views/Service/Index.razor +++ b/Moonlight/Shared/Views/Service/Index.razor @@ -5,6 +5,7 @@ @using Moonlight.App.Services.ServiceManage @using Microsoft.EntityFrameworkCore @using Moonlight.App.Models.Abstractions.Services +@using Moonlight.App.Models.Enums @using Moonlight.App.Services @inject Repository ServiceRepository @@ -19,7 +20,8 @@ } else { - if (NeedsRenewal) + // An admin should still be able to manage the service, that's why we check for permissions here + if (NeedsRenewal && !IdentityService.Permissions[Permission.AdminServices]) { } @@ -50,7 +52,7 @@ private ServiceDefinition Definition; private ServiceViewContext ViewContext; - private bool NeedsRenewal = false; + private bool NeedsRenewal; private async Task Load(LazyLoader lazyLoader) { @@ -73,9 +75,12 @@ if (Service == null) return; + // Check expiration NeedsRenewal = await ServiceService.Manage.NeedsRenewal(Service); - if(NeedsRenewal) // Stop loading more data + // Stop loading more data if the user is not an admin + // because a admin should still be able to manage the service + if(NeedsRenewal && !IdentityService.Permissions[Permission.AdminServices]) return; // Load implementation From e47cac71fc565f6242e3899c84ae7eb626c80c6b Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Fri, 5 Jan 2024 11:05:35 +0100 Subject: [PATCH 2/2] Added a proper error message when starting a charge process without selecting a payment gateway --- Moonlight/Shared/Views/Account/Payments.razor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Moonlight/Shared/Views/Account/Payments.razor b/Moonlight/Shared/Views/Account/Payments.razor index ba00877..72a0d5a 100644 --- a/Moonlight/Shared/Views/Account/Payments.razor +++ b/Moonlight/Shared/Views/Account/Payments.razor @@ -134,7 +134,7 @@ private async Task LaunchPayment() { if (SelectedGateway == null) - return; + throw new DisplayException("You need to select a payment method"); var url = await SelectedGateway.Start(Amount); Navigation.NavigateTo(url, true);