diff --git a/samples/SamplePermissions/InvoicesDbContext.cs b/samples/SamplePermissions/InvoicesDbContext.cs index 43d0b02..eccd84c 100644 --- a/samples/SamplePermissions/InvoicesDbContext.cs +++ b/samples/SamplePermissions/InvoicesDbContext.cs @@ -1,5 +1,6 @@ namespace SamplePermissions { + using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.ValueGeneration; using SamplePermissions.Model; diff --git a/samples/SamplePermissions/Model/Invoice.cs b/samples/SamplePermissions/Model/Invoice.cs index 654c06c..e488d1a 100644 --- a/samples/SamplePermissions/Model/Invoice.cs +++ b/samples/SamplePermissions/Model/Invoice.cs @@ -1,5 +1,7 @@ namespace SamplePermissions.Model { + using System; + public class Invoice { public Guid Id { get; set; } diff --git a/samples/SamplePermissions/Pages/Error.cshtml.cs b/samples/SamplePermissions/Pages/Error.cshtml.cs index 7eae98d..c71863d 100644 --- a/samples/SamplePermissions/Pages/Error.cshtml.cs +++ b/samples/SamplePermissions/Pages/Error.cshtml.cs @@ -3,19 +3,20 @@ namespace SamplePermissions.Pages using System.Diagnostics; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; + using Microsoft.Extensions.Logging; [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] [IgnoreAntiforgeryToken] public class ErrorModel : PageModel { - private readonly ILogger _logger; + private readonly ILogger logger; public ErrorModel(ILogger logger) { - this._logger = logger; + this.logger = logger; } - public string? RequestId { get; set; } + public string RequestId { get; set; } public bool ShowRequestId => !string.IsNullOrEmpty(this.RequestId); diff --git a/samples/SamplePermissions/Pages/Index.cshtml.cs b/samples/SamplePermissions/Pages/Index.cshtml.cs index ce78c19..c10dc7e 100644 --- a/samples/SamplePermissions/Pages/Index.cshtml.cs +++ b/samples/SamplePermissions/Pages/Index.cshtml.cs @@ -1,14 +1,15 @@ namespace SamplePermissions.Pages { using Microsoft.AspNetCore.Mvc.RazorPages; + using Microsoft.Extensions.Logging; public class IndexModel : PageModel { - private readonly ILogger _logger; + private readonly ILogger logger; public IndexModel(ILogger logger) { - this._logger = logger; + this.logger = logger; } public void OnGet() diff --git a/samples/SamplePermissions/Pages/InvoiceDelete.cshtml.cs b/samples/SamplePermissions/Pages/InvoiceDelete.cshtml.cs index 1e740cc..73f514a 100644 --- a/samples/SamplePermissions/Pages/InvoiceDelete.cshtml.cs +++ b/samples/SamplePermissions/Pages/InvoiceDelete.cshtml.cs @@ -1,17 +1,20 @@ namespace SamplePermissions.Pages { + using System; + using System.Linq; using AspNetCore.Authorization.Permissions; using Microsoft.AspNetCore.Mvc.RazorPages; + using Microsoft.Extensions.Logging; using SamplePermissions.Model; [HasPermission("Invoice.Delete")] public class InvoiceDeleteModel : PageModel { - private readonly ILogger _logger; + private readonly ILogger logger; public InvoiceDeleteModel(ILogger logger, InvoicesDbContext context) { - this._logger = logger; + this.logger = logger; this.Context = context; } diff --git a/samples/SamplePermissions/Pages/InvoicePayment.cshtml.cs b/samples/SamplePermissions/Pages/InvoicePayment.cshtml.cs index 4db6701..44fb5a8 100644 --- a/samples/SamplePermissions/Pages/InvoicePayment.cshtml.cs +++ b/samples/SamplePermissions/Pages/InvoicePayment.cshtml.cs @@ -2,15 +2,16 @@ { using AspNetCore.Authorization.Permissions; using Microsoft.AspNetCore.Mvc.RazorPages; + using Microsoft.Extensions.Logging; [HasPermission("Invoice.Payment")] public class InvoicePaymentModel : PageModel { - private readonly ILogger _logger; + private readonly ILogger logger; public InvoicePaymentModel(ILogger logger, ApplicationDbContext context) { - this._logger = logger; + this.logger = logger; this.Context = context; } diff --git a/samples/SamplePermissions/Pages/InvoiceRead.cshtml.cs b/samples/SamplePermissions/Pages/InvoiceRead.cshtml.cs index f973357..6f8e02a 100644 --- a/samples/SamplePermissions/Pages/InvoiceRead.cshtml.cs +++ b/samples/SamplePermissions/Pages/InvoiceRead.cshtml.cs @@ -1,18 +1,18 @@ namespace SamplePermissions.Pages { using AspNetCore.Authorization.Permissions.Abstractions; - using Fluxera.Utilities.Extensions; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; + using Microsoft.Extensions.Logging; // [HasPermission("Invoice.Read")] public class InvoiceReadModel : PageModel { - private readonly ILogger _logger; + private readonly ILogger logger; public InvoiceReadModel(ILogger logger, InvoicesDbContext context) { - this._logger = logger; + this.logger = logger; this.Context = context; } @@ -22,7 +22,7 @@ public IActionResult OnGet() { if(!this.User.HasPermission("Invoice.Read")) { - if(this.User.IsAuthenticated()) + if(this.User.Identity != null && this.User.Identity.IsAuthenticated) { return this.Forbid(); } diff --git a/samples/SamplePermissions/Pages/InvoiceSend.cshtml.cs b/samples/SamplePermissions/Pages/InvoiceSend.cshtml.cs index 5b4826a..e21d337 100644 --- a/samples/SamplePermissions/Pages/InvoiceSend.cshtml.cs +++ b/samples/SamplePermissions/Pages/InvoiceSend.cshtml.cs @@ -2,15 +2,16 @@ { using AspNetCore.Authorization.Permissions; using Microsoft.AspNetCore.Mvc.RazorPages; + using Microsoft.Extensions.Logging; [HasPermission("Invoice.Send")] public class InvoiceSendModel : PageModel { - private readonly ILogger _logger; + private readonly ILogger logger; public InvoiceSendModel(ILogger logger, ApplicationDbContext context) { - this._logger = logger; + this.logger = logger; this.Context = context; } diff --git a/samples/SamplePermissions/Pages/InvoiceWrite.cshtml.cs b/samples/SamplePermissions/Pages/InvoiceWrite.cshtml.cs index c883654..7b93a3f 100644 --- a/samples/SamplePermissions/Pages/InvoiceWrite.cshtml.cs +++ b/samples/SamplePermissions/Pages/InvoiceWrite.cshtml.cs @@ -2,16 +2,17 @@ { using AspNetCore.Authorization.Permissions; using Microsoft.AspNetCore.Mvc.RazorPages; + using Microsoft.Extensions.Logging; using SamplePermissions.Model; [HasPermission("Invoice.Write")] public class InvoiceWriteModel : PageModel { - private readonly ILogger _logger; + private readonly ILogger logger; public InvoiceWriteModel(ILogger logger, InvoicesDbContext context) { - this._logger = logger; + this.logger = logger; this.Context = context; } diff --git a/samples/SamplePermissions/Pages/Invoices.cshtml.cs b/samples/SamplePermissions/Pages/Invoices.cshtml.cs index b09edcc..1e40e95 100644 --- a/samples/SamplePermissions/Pages/Invoices.cshtml.cs +++ b/samples/SamplePermissions/Pages/Invoices.cshtml.cs @@ -2,15 +2,16 @@ { using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc.RazorPages; + using Microsoft.Extensions.Logging; [Authorize] public class InvoicesModel : PageModel { - private readonly ILogger _logger; + private readonly ILogger logger; public InvoicesModel(ILogger logger) { - this._logger = logger; + this.logger = logger; } public void OnGet() diff --git a/samples/SamplePermissions/Pages/Permissions.cshtml.cs b/samples/SamplePermissions/Pages/Permissions.cshtml.cs index 4e09d49..719afe5 100644 --- a/samples/SamplePermissions/Pages/Permissions.cshtml.cs +++ b/samples/SamplePermissions/Pages/Permissions.cshtml.cs @@ -2,15 +2,16 @@ { using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc.RazorPages; + using Microsoft.Extensions.Logging; [Authorize] public class PermissionsModel : PageModel { - private readonly ILogger _logger; + private readonly ILogger logger; public PermissionsModel(ILogger logger) { - this._logger = logger; + this.logger = logger; } public void OnGet() diff --git a/samples/SamplePermissions/Pages/Shared/_Layout.cshtml b/samples/SamplePermissions/Pages/Shared/_Layout.cshtml index d34c783..0410a6d 100644 --- a/samples/SamplePermissions/Pages/Shared/_Layout.cshtml +++ b/samples/SamplePermissions/Pages/Shared/_Layout.cshtml @@ -1,5 +1,4 @@ -@using Fluxera.Utilities.Extensions - + @@ -23,7 +22,7 @@ - @if(this.User.IsAuthenticated()) + @if (this.User.Identity != null && this.User.Identity.IsAuthenticated) {