From 87f93b3caba040a6c555df985ab089f20b67ca1c Mon Sep 17 00:00:00 2001 From: Moritz Deiaco Date: Sat, 8 Jun 2024 12:02:00 +0200 Subject: [PATCH] Added Cookie Settings option on the account settings --- .../Core/Models/Forms/ChangeCookiesForm.cs | 9 +++++ .../Core/UI/Views/Account/Security.razor | 33 ++++++++++++++++--- 2 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 Moonlight/Core/Models/Forms/ChangeCookiesForm.cs diff --git a/Moonlight/Core/Models/Forms/ChangeCookiesForm.cs b/Moonlight/Core/Models/Forms/ChangeCookiesForm.cs new file mode 100644 index 00000000..0090240e --- /dev/null +++ b/Moonlight/Core/Models/Forms/ChangeCookiesForm.cs @@ -0,0 +1,9 @@ +using System.ComponentModel; + +namespace Moonlight.Core.Models.Forms; + +public class ChangeCookiesForm +{ + [Description("This specifies if you would like to personalize your experience with optional cookies.")] + public bool UseOptionalCookies { get; set; } = false; +} \ No newline at end of file diff --git a/Moonlight/Core/UI/Views/Account/Security.razor b/Moonlight/Core/UI/Views/Account/Security.razor index eb69af0a..7c2cb050 100644 --- a/Moonlight/Core/UI/Views/Account/Security.razor +++ b/Moonlight/Core/UI/Views/Account/Security.razor @@ -28,7 +28,7 @@
- +
@@ -47,19 +47,37 @@
+
+
+ +
+

Cookies

+
+ + +
+
+ +
+
+
@code { private readonly ChangePasswordForm PasswordForm = new(); + + private ChangeCookiesForm CookiesForm = new(); - private Task Load(LazyLoader lazyLoader) + private async Task Load(LazyLoader lazyLoader) { - return Task.CompletedTask; + CookiesForm.UseOptionalCookies = await IdentityService.HasFlag("CookieConsent"); } - private async Task OnValidSubmit() + private async Task OnValidSubmitPassword() { if (PasswordForm.Password != PasswordForm.RepeatedPassword) throw new DisplayException("The passwords do not match"); @@ -69,4 +87,11 @@ await ToastService.Success("Successfully changed password"); await IdentityService.Authenticate(true); } + + private async Task OnValidSubmitCookie() + { + await IdentityService.SetFlag("CookieConsent", CookiesForm.UseOptionalCookies); + + await InvokeAsync(StateHasChanged); + } } \ No newline at end of file