fix: read user roles from frappe.boot instead of REST API (prevents Has Role permission issue) - #248
Open
CodeMaistro wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a user logs into the POS SPA, getUserRoles() calls db.getDoc("User", email) to fetch the user roles. Frappe REST API strips child table data (including the roles child table) when the caller lacks Read on the Has Role doctype.
Has Role permissions cannot be granted via the Role Permissions Manager in Desk — child table doctypes are excluded from that UI (frappe/frappe#32378). So the POS login always returns an empty roles array on any production deployment.
Fix
Read user roles from frappe.boot.user.roles — same mechanism Frappe Desk uses. No REST API call, no permission dependency.
Changes
3 files changed: packages/core/src/frappe/auth.ts (dropped db.getDoc, read from frappe.boot.user, removed unused email param), pos/src/store/slices/auth-slice.ts (updated caller), packages/core/AGENTS.MD (docs updated).
Backport
Bug also exists in v0.2.2 (pos/src/lib/auth-api.ts). Patched branch patched-v0.2.2 at CodeMaistro/ury-pos-patched for production users.