parse-community / parse-community/parse-server

Add method to get all roles of a `Parse.User`

Open
#8,124 6 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type:feature
Dominant language
JavaScript
Stars
21.4k
Forks
4.8k
Avg merge
7h 45m
Merged PRs (30d)
11

Description

New Feature / Enhancement Checklist
Current Limitation

Currently, to get what Roles a user has been assigned, you would need have your own method either to run a query to get Roles the current user has.

Feature / Enhancement Description

I'm hoping that we have a getUserRoles method on the Parse.User object where we can just call the currentUser object and receive an array of Role objects the user has been assigned.

Example Use Case

let currentUserRoles = currentUser.getUserRoles()

Alternatives / Workarounds

Currently, we have to make our own method to run the query like so

Parse.Cloud.define("getUserRoles", async (request) => {
	const { user } = request
	
	return await new Parse.Query(Parse.Role).equalTo("users", user).find({useMasterKey:true})
}, {
    requireAnyUserRoles: ["admin"]
})
3rd Party References

none that I can think of.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the Parse.User, Parse.Role, Parse.Query, and Parse.Cloud entry points named in the issue to determine where a user-to-role lookup belongs and how the public method should expose it. Define the expected behavior for the current user and confirm that the completed method returns the assigned Role objects without requiring a custom Cloud function.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
authorization, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.