Obtain a list of all users who have a specific custom claim using Vue and

I have a unique claim "admin" attached to each user, containing a boolean value. Currently, in the frontend of my application, I am attempting to create a list of all administrators. To do so, I need to retrieve all users who have this specific custom claim set to "true" and store them in an array, from which I can easily generate the list. The array structure should resemble the following:

const admins = ref([
    {
        uid: *UID of admin1*,
        name: *Name of admin1*,
    },
    {
        uid: *UID of admin2*,
        name: *Name of admin2*,
    },
    ...
])

Unfortunately, I am facing the following challenges:

  1. How can I access all users with the custom claim set to true in order to iterate over them and populate my array?
  2. Would implementing a cloud function be a feasible solution to prevent manipulation?

Although I attempted to comprehend the information provided in this Firebase documentation, it did not provide much clarity.

Answer №1

How can I retrieve all users with a specific custom claim set to true, in order to iterate over them and populate an array?

There isn't a straightforward method for querying users based on custom claims.

Would using a cloud function be the solution in this scenario?

Yes, you would need to enumerate all users as outlined in the documentation you provided and then check each user individually for the custom claim.


It might be more suitable to utilize a database such as Firestore or Realtime Database and maintain a collection of all administrators. Ensure that this collection cannot be modified directly from the client side by implementing security rules.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What strategies can I use to successfully navigate through this component?

I'm looking to display "favorite" items within my favorites component. However, I'm facing a challenge since I can't directly pass the postList component to the favorites component. Essentially, I aim to showcase these favorite items on ano ...

How can I convert a list of checkboxes, generated by ng-repeat, into multiple columns?

Here is the HTML code snippet: <div class="checkbox"> <label> <input type="checkbox" ng-model="selectedAll.value" ng-click="checkAll()" />Check All </label> </div> <div class="checkbox" ng-repeat="carType i ...

When utilizing the `express.static(__dirname)` function in Node.js with Express, the visitor may be directed to an incorrect HTML page

My website consists of a login page named login.html and an index page named index.html. I want to implement authentication so that only logged in users can access the index page. I have not set up the post method on the login HTML page. Therefore, I have ...

Retrieving information using getStaticProps

I'm currently working on a new function that pulls data from The Guardian API, but I've hit a roadblock with an error message. Below is the response that's being returned: https://i.sstatic.net/90OoB.png Furthermore, presented here is the c ...

Modify the text and purpose of the button

I have a button that I would like to customize. Here is the HTML code for the button: <button class="uk-button uk-position-bottom" onclick="search.start()">Start search</button> The corresponding JavaScript code is as follows: var search = n ...

Invoke a PHP function located in a separate file using a JavaScript function to fetch data from a database

How can I properly call a PHP function from a JavaScript function located in a different file? I am trying to pass a variable from an onClick function in JavaScript to a PHP function, which will then access a MySQL database to retrieve data. However, my c ...

The imported `theme` as `theme` was not visible in the file './theme'. The only possible export in the file is `default`

Encountering an error while attempting to export the theme from the index.js file. Below is the snippet of code present in the index.js file. import { createTheme } from "@mui/material"; import shadows from "./shadows"; import typograph ...

considering multiple website addresses as one collective entity for the Facebook like button

Currently, I am tackling an issue on a website that employs a custom CMS which automatically generates URLs based on the titles of articles. The main problem faced by our contributors is that when they update the title of an article, it creates a new URL ...

Trigger a jQuery event when an element is moved to a new line

Is there a way to trigger a jQuery event when an element moves to a new line in the view? I want to hide navigation items and run additional JavaScript code when this happens. Any ideas on how to achieve this? Here's how my navigation appears in a wi ...

A guide on effectively refining a JSON object using req.query.params

I have a node.js and express project where I need to extract specific results from an array of JSON objects Here is the array of objects I am working with: [ { id: 1, name: "Person 1", boughtItems: { item: "Shoes", c ...

Infrastructural setup for multiplayer games using Socket.io

var connectionHandler = function(socket) { var player = null; socket.on('login', function(data) { player = { data: okeyServer.playerJoin(data), socket: socket }; socket.emit('welcome'); }); socket. ...

Having trouble decoding audio data in JavaScript Web Audio?

I'm attempting to utilize the Web Audio API in JavaScript to upload a sound into a buffer and play it. However, I am encountering an issue where it does not work and an error message is displayed: Uncaught TypeError: Failed to set the 'buffer&ap ...

Efficiently monitor several Vue.js properties with a single handler function

Currently I am tasked with monitoring several properties. However, whenever each one of them changes, I must trigger the same function: export default{ // ...... rest of code watch: { propa: function(after,before) { doSomething(after,before ...

What is the best way to manage an empty JavaScript object?

I'm feeling stuck. Check out this code snippet: const clientInfoPromise = buildPromiseMethod clientInfoPromise.then((clients) => { console.log('clients ' + JSON.stringify(clients)) console.log(clients.typeOf) console.log(_.k ...

Whenever I try to retrieve data from MongoDB using Node.js, I consistently encounter a timeout error

Currently, I am in the process of developing a website using React.js for the front end, Node.js for the back end, and MongoDB as the database. Dummy data has been inserted into the database which can be viewed https://i.sstatic.net/YOzCB.png. The database ...

Having issues with clicking on a row in the table while using AJAX functionality

Experiencing a puzzling issue while attempting to add click functionality to table rows with AJAX, here is the JavaScript code used: //for tabs $(document).ready(function () { $("#tabs").tabs(); }); $(window).load(function() { jsf.ajax.addOnEven ...

JavaScript function overriding

Joomla.updatebutton is a vital javascript function within the Joomla platform. It is invoked upon submitting a form when a user clicks on either the cancel or save button. I have customized this function in the following manner: saveFunction = Joomla.subm ...

Enable JavaScript in Webdriver Selenium to enhance the functionality of your web

I am facing an issue with my Java program and Selenium WebDriver. The script I have does not detect the button "Open device access" because its style is set to "display: none". Usually, clicking on "Device Access" triggers JavaScript to display the "Open ...

You cannot invoke this expression while destructuring an array of React hooks in TypeScript

Within my React TypeScript component, I have several fields that check a specific condition. If the condition is not met, the corresponding field error is set to true in order to be reflected in the component's DOM and prevent submission. However, whe ...

The callback functions designed to ascertain non-conflicting time ranges are harmoniously aligned

Suppose I have a JSON dataset of events, each with start and end times, and I want to create a function that generates time ranges without conflicts. For example, if the dataset includes 0800-0845, 1200-1230, 1140-1240, 1430-1530, etc., how can I gray ou ...