Consent: optional at registration, a consent page, CSRF-guarded accept/withdraw, notice v2 (#58)
This commit is contained in:
parent
028bc2fdf6
commit
1571bf3e32
17 changed files with 1141 additions and 266 deletions
|
|
@ -325,7 +325,8 @@ public sealed class BifrostDbContext(DbContextOptions<BifrostDbContext> options)
|
|||
|
||||
modelBuilder.Entity<ConsentReceipt>(entity =>
|
||||
{
|
||||
entity.HasIndex(x => new { x.UserAccountId, x.NoticeVersion }).IsUnique();
|
||||
// One live receipt per account and version; a withdrawn row stays as history and a later agreement is a new row.
|
||||
entity.HasIndex(x => new { x.UserAccountId, x.NoticeVersion }).IsUnique().HasFilter("\"WithdrawnAtUtc\" IS NULL");
|
||||
entity.HasOne(x => x.UserAccount)
|
||||
.WithMany()
|
||||
.HasForeignKey(x => x.UserAccountId)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
using Bifrost.Web.Data;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Bifrost.Web.Data.Migrations
|
||||
{
|
||||
// Hand-written like AddConsentReceipts: no dotnet-ef on the authoring host; the snapshot was edited to match.
|
||||
// A person may withdraw and agree again to the same version, so uniqueness narrows to the live receipt.
|
||||
[DbContext(typeof(BifrostDbContext))]
|
||||
[Migration("20261111100000_ConsentReceiptsOneLivePerVersion")]
|
||||
public partial class ConsentReceiptsOneLivePerVersion : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(name: "IX_ConsentReceipts_UserAccountId_NoticeVersion", table: "ConsentReceipts");
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ConsentReceipts_UserAccountId_NoticeVersion",
|
||||
table: "ConsentReceipts",
|
||||
columns: new[] { "UserAccountId", "NoticeVersion" },
|
||||
unique: true,
|
||||
filter: "\"WithdrawnAtUtc\" IS NULL");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(name: "IX_ConsentReceipts_UserAccountId_NoticeVersion", table: "ConsentReceipts");
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ConsentReceipts_UserAccountId_NoticeVersion",
|
||||
table: "ConsentReceipts",
|
||||
columns: new[] { "UserAccountId", "NoticeVersion" },
|
||||
unique: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1461,7 +1461,8 @@ namespace Bifrost.Web.Data.Migrations
|
|||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserAccountId", "NoticeVersion")
|
||||
.IsUnique();
|
||||
.IsUnique()
|
||||
.HasFilter("\"WithdrawnAtUtc\" IS NULL");
|
||||
|
||||
b.ToTable("ConsentReceipts");
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue