Skip to content

Add method to get all roles of a Parse.User #8124

@jaysonng

Description

@jaysonng

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:featureNew feature or improvement of existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions