Skip to content

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
ury-erp:developfrom
CodeMaistro:fix/auth-read-roles-from-boot
Open

fix: read user roles from frappe.boot instead of REST API (prevents Has Role permission issue)#248
CodeMaistro wants to merge 1 commit into
ury-erp:developfrom
CodeMaistro:fix/auth-read-roles-from-boot

Conversation

@CodeMaistro

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant