[PR #2567] [CLOSED] Expose User and Session in userHasPermission Response #4382

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/2567
Author: @htmujahid
Created: 5/7/2025
Status: Closed

Base: mainHead: main


📝 Commits (1)

📊 Changes

1 file changed (+9 additions, -1 deletions)

View changed files

📝 packages/better-auth/src/plugins/admin/admin.ts (+9 -1)

📄 Description

Currently, userHasPermission internally fetches the active user to evaluate permissions but doesn't expose the user or session in the response. As a result, consumers of this function (like API endpoints) are forced to make an additional DB call to retrieve the same user for downstream logic (e.g., using user.id as a foreign key).

This PR updates userHasPermission to return the user and session objects alongside success and error to avoid redundant lookups and improve efficiency.


🔄 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/2567 **Author:** [@htmujahid](https://github.com/htmujahid) **Created:** 5/7/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (1) - [`bd93b0b`](https://github.com/better-auth/better-auth/commit/bd93b0bfa57f8f463719bf8bbd334530bde0923a) Update admin.ts ### 📊 Changes **1 file changed** (+9 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/admin/admin.ts` (+9 -1) </details> ### 📄 Description Currently, userHasPermission internally fetches the active user to evaluate permissions but doesn't expose the user or session in the response. As a result, consumers of this function (like API endpoints) are forced to make an additional DB call to retrieve the same user for downstream logic (e.g., using user.id as a foreign key). This PR updates userHasPermission to return the user and session objects alongside success and error to avoid redundant lookups and improve efficiency. --- <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:43: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#4382