I've implemented Firebase Authentication in my app with role-based API using firebase admin. When retrieving a user's data or listing all user's data from firebase, it does not include the user's disabled status.
I'm attempting to create the ability for app administrators to tell if a user account is Active or Disabled, and have the option to "flip the switch" as needed to manage their users.
Here are my controllers for each route in the API:
List all Users
// list all users route
app.get('/users', [
authenticationCheck.isAuthenticated,
authorizedCheck.isAuthorized({ hasRole: ['admin', 'user'] }),
indexController.all,
])
// list all users controller
async function all(req, res) {
try {
const listUsers = await admin.auth().listUsers(),
users = listUsers.users.map(mapUser)
console.log('userList', users)
return res.status(200).send({ users })
} catch (err) {
return handleError(res, err)
}
}
Get user by id
// get user by id route
app.get('/users/:id', [
authenticationCheck.isAuthenticated,
authorizedCheck.isAuthorized(
{ hasRole: ['admin', 'user'], allowSameUser: true },
),
indexController.get,
])
// get user by id controller
async function get(req, res) {
try {
const { id } = req.params,
user = await admin.auth().getUser(id)
return res.status(200).send({ user: mapUser(user) })
} catch (err) {
return handleError(res, err)
}
}
Am I missing something? How do I retrieve a user's disabled status from Firebase using Firebase Admin?
Update
This issue is resolved. I found that the I wasn't mapping "disabled" in the mapUser function that I am using to also map customClaims.