[PR #5258] Feat/legal plugin #14131

Open
opened 2026-04-13 09:19:42 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5258
Author: @R5dan
Created: 10/12/2025
Status: 🔄 Open

Base: mainHead: feat/tos-plugin


📝 Commits (8)

📊 Changes

11 files changed (+1131 additions, -115 deletions)

View changed files

📝 docs/app/docs/[[...slug]]/page.tsx (+5 -1)
📝 docs/components/api-method.tsx (+1 -1)
📝 docs/components/builder/code-tabs/index.tsx (+36 -6)
📝 docs/components/builder/index.tsx (+94 -5)
docs/components/builder/legal.tsx (+131 -0)
📝 docs/components/builder/sign-in.tsx (+4 -4)
📝 docs/components/builder/sign-up.tsx (+313 -98)
📝 docs/components/builder/store.ts (+7 -0)
📝 docs/components/sidebar-content.tsx (+5 -0)
docs/content/docs/plugins/legal.mdx (+248 -0)
packages/better-auth/src/plugins/legal/index.ts (+287 -0)

📄 Description

Summary by cubic

Adds a Legal plugin that lets apps require users to read and/or accept documents (e.g., Terms, Privacy) before sign up or sign in. Includes API endpoints, schema hooks, docs, and builder UI/code generation.

  • New Features

    • legal() plugin with document rules, optional blocking for sign up/sign in, and cookie-based tracking.
    • Enforces requirements pre sign up/sign in; migrates cookie-based records to the user after account creation.
    • Endpoints:
      • POST /legal/action to mark a document as viewed or accepted.
      • GET /legal/list to fetch a user’s or cookie’s document status.
    • User payload can include per-document fields like {name}AcceptedAt and {name}ViewedAt.
    • Docs site: new Legal plugin page, sidebar link, and custom type table support.
    • Builder: new “Legal” toggle, document editor step, generated sign-up checkboxes, and example legal pages in code tabs.
  • Migration

    • Add legal() to betterAuth plugins and define your documents.
    • If desired, include {name}AcceptedAt and {name}ViewedAt in sign up/sign in requests.
    • Use POST /legal/action to record views/acceptance; use GET /legal/list to inspect status.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/5258 **Author:** [@R5dan](https://github.com/R5dan) **Created:** 10/12/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/tos-plugin` --- ### 📝 Commits (8) - [`184abd2`](https://github.com/better-auth/better-auth/commit/184abd2b60c08192cd057d1be30aa77b194b32c2) legal plugin - [`3c7ddb6`](https://github.com/better-auth/better-auth/commit/3c7ddb65f724c2d34ca2aff06263a94c2b7daa7b) docs - [`1116d60`](https://github.com/better-auth/better-auth/commit/1116d60f1d5603a9d2d9343c3c6fd92bd3d3eab1) fix builder - [`051d59c`](https://github.com/better-auth/better-auth/commit/051d59c626ed6c1a10cea63575d49dfb6964deb7) docs - [`885d9c2`](https://github.com/better-auth/better-auth/commit/885d9c2b44689aeff95af172681d7e953086391f) fixes - [`ff404a8`](https://github.com/better-auth/better-auth/commit/ff404a8d51cd6634ea6cc288875cdfcef785eb08) format - [`ab2f57b`](https://github.com/better-auth/better-auth/commit/ab2f57b686faa8f74949c1aa5de0168c4fc3f759) change imports - [`fb7cb03`](https://github.com/better-auth/better-auth/commit/fb7cb03fc682995fcc37694543783d8bad45c7c3) edit docs ### 📊 Changes **11 files changed** (+1131 additions, -115 deletions) <details> <summary>View changed files</summary> 📝 `docs/app/docs/[[...slug]]/page.tsx` (+5 -1) 📝 `docs/components/api-method.tsx` (+1 -1) 📝 `docs/components/builder/code-tabs/index.tsx` (+36 -6) 📝 `docs/components/builder/index.tsx` (+94 -5) ➕ `docs/components/builder/legal.tsx` (+131 -0) 📝 `docs/components/builder/sign-in.tsx` (+4 -4) 📝 `docs/components/builder/sign-up.tsx` (+313 -98) 📝 `docs/components/builder/store.ts` (+7 -0) 📝 `docs/components/sidebar-content.tsx` (+5 -0) ➕ `docs/content/docs/plugins/legal.mdx` (+248 -0) ➕ `packages/better-auth/src/plugins/legal/index.ts` (+287 -0) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Adds a Legal plugin that lets apps require users to read and/or accept documents (e.g., Terms, Privacy) before sign up or sign in. Includes API endpoints, schema hooks, docs, and builder UI/code generation. - New Features - legal() plugin with document rules, optional blocking for sign up/sign in, and cookie-based tracking. - Enforces requirements pre sign up/sign in; migrates cookie-based records to the user after account creation. - Endpoints: - POST /legal/action to mark a document as viewed or accepted. - GET /legal/list to fetch a user’s or cookie’s document status. - User payload can include per-document fields like {name}AcceptedAt and {name}ViewedAt. - Docs site: new Legal plugin page, sidebar link, and custom type table support. - Builder: new “Legal” toggle, document editor step, generated sign-up checkboxes, and example legal pages in code tabs. - Migration - Add legal() to betterAuth plugins and define your documents. - If desired, include {name}AcceptedAt and {name}ViewedAt in sign up/sign in requests. - Use POST /legal/action to record views/acceptance; use GET /legal/list to inspect status. <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-13 09:19:42 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#14131