[PR #2723] [MERGED] fix consent not able to be accepted if state is empty oidcProvider #4454

Closed
opened 2026-03-13 11:47:38 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/2723
Author: @zackify
Created: 5/20/2025
Status: Merged
Merged: 5/20/2025
Merged by: @Bekacru

Base: mainHead: patch-1


📝 Commits (2)

  • e5eaba8 fix consent not able to be accepted if state is empty
  • 245e501 chore: fix lint

📊 Changes

2 files changed (+2 additions, -3 deletions)

View changed files

📝 dev/bun/auth.ts (+0 -1)
📝 packages/better-auth/src/plugins/oidc-provider/index.ts (+2 -2)

📄 Description

When using the oidc provider.

if i do not set a consent page, i get an error.

So I added one:

consentPage: "/api/auth/consent",

Since i didn't really need one, i just did this in the route:

  app.get("/api/auth/consent", async (req, res) => {
    try {
      const data = await auth.api.oAuthConsent({
        body: { accept: true },
        query: req.query,
        headers: req.headers,
      });
      res.redirect(data.redirectURI);
    } catch (e) {
      console.error(e);
    }
  });

This doesnt even work, because there is a line checking if the verification has a state param, which should be optional. just removing this one check, allows oauthConsent to be accepted. Doesn't make sense to throw an error when consent is required but state is empty?


🔄 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/2723 **Author:** [@zackify](https://github.com/zackify) **Created:** 5/20/2025 **Status:** ✅ Merged **Merged:** 5/20/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `main` ← **Head:** `patch-1` --- ### 📝 Commits (2) - [`e5eaba8`](https://github.com/better-auth/better-auth/commit/e5eaba88343fdac4cbca257071c1668f41170049) fix consent not able to be accepted if state is empty - [`245e501`](https://github.com/better-auth/better-auth/commit/245e5017d112b898c11acbb0443ac1645ab4f893) chore: fix lint ### 📊 Changes **2 files changed** (+2 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `dev/bun/auth.ts` (+0 -1) 📝 `packages/better-auth/src/plugins/oidc-provider/index.ts` (+2 -2) </details> ### 📄 Description When using the oidc provider. if i do not set a consent page, i get an error. So I added one: ``` consentPage: "/api/auth/consent", ``` Since i didn't really need one, i just did this in the route: ``` app.get("/api/auth/consent", async (req, res) => { try { const data = await auth.api.oAuthConsent({ body: { accept: true }, query: req.query, headers: req.headers, }); res.redirect(data.redirectURI); } catch (e) { console.error(e); } }); ``` This doesnt even work, because there is a line checking if the verification has a state param, which should be optional. just removing this one check, allows oauthConsent to be accepted. Doesn't make sense to throw an error when consent is required but state is empty? --- <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-03-13 11:47:38 -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#4454