Added Cookie Settings option on the account settings
This commit is contained in:
9
Moonlight/Core/Models/Forms/ChangeCookiesForm.cs
Normal file
9
Moonlight/Core/Models/Forms/ChangeCookiesForm.cs
Normal file
@@ -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;
|
||||||
|
}
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
<div class="row g-5">
|
<div class="row g-5">
|
||||||
<div class="col-md-6 col-12">
|
<div class="col-md-6 col-12">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<SmartForm Model="PasswordForm" OnValidSubmit="OnValidSubmit">
|
<SmartForm Model="PasswordForm" OnValidSubmit="OnValidSubmitPassword">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<AutoForm Model="PasswordForm" Columns="12" />
|
<AutoForm Model="PasswordForm" Columns="12" />
|
||||||
@@ -47,6 +47,22 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-md-6 col-12">
|
||||||
|
<div class="card h-100">
|
||||||
|
<SmartForm Model="CookiesForm" OnValidSubmit="OnValidSubmitCookie">
|
||||||
|
<div class="card-body">
|
||||||
|
<h3>Cookies</h3>
|
||||||
|
<div>
|
||||||
|
|
||||||
|
<AutoForm Model="CookiesForm"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card-footer d-flex justify-content-end">
|
||||||
|
<button class="btn btn-primary" type="submit">Save changes</button>
|
||||||
|
</div>
|
||||||
|
</SmartForm>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
|
|
||||||
@@ -54,12 +70,14 @@
|
|||||||
{
|
{
|
||||||
private readonly ChangePasswordForm PasswordForm = new();
|
private readonly ChangePasswordForm PasswordForm = new();
|
||||||
|
|
||||||
private Task Load(LazyLoader lazyLoader)
|
private ChangeCookiesForm CookiesForm = new();
|
||||||
|
|
||||||
|
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)
|
if (PasswordForm.Password != PasswordForm.RepeatedPassword)
|
||||||
throw new DisplayException("The passwords do not match");
|
throw new DisplayException("The passwords do not match");
|
||||||
@@ -69,4 +87,11 @@
|
|||||||
await ToastService.Success("Successfully changed password");
|
await ToastService.Success("Successfully changed password");
|
||||||
await IdentityService.Authenticate(true);
|
await IdentityService.Authenticate(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task OnValidSubmitCookie()
|
||||||
|
{
|
||||||
|
await IdentityService.SetFlag("CookieConsent", CookiesForm.UseOptionalCookies);
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user