isUserInAnyRoles()

This function is designed to check whether a user is assigned to any of the specified roles within a system. It provides a way to verify whether a user possesses at least one of the roles provided in the roles array.

Here is an Example:

import { createBackendFunction, utils } from "@magicjs.dev/backend"

export default createBackendFunction(
  async function (userId,roles) {
    const userIsInAdminRole = await utils.isUserInAnyRoles(String(userId), roles);
    return userIsInAdminRole
  },
)

Click here to refer GitHub.

Last updated