To remove a role that's available for users, the accounts.roles.remove()
method can be utilized.
Example Usage
index.server.js
import joystick, { accounts } from '@joystick.js/node';
joystick.app({
...
}).then(() => {
accounts.roles.remove('manager');
});
Above, we tap into the .then()
callback that's triggered internally by joystick.app()
after our server starts up. Inside, we call to accounts.roles.remove('manager')
to remove the manager
role from our database.
When we run accounts.roles.remove()
, the passed role
is removed from the global roles
collection/table, but also from all users who currently have it granted. This is a great way to migrate between roles, or to bulk remove a role that no longer exists without having to worry about security leaks.
API
Definition
accounts.roles.remove(role: string) => void;
Parameters
- role string required
- A string defining the name of the role to remove from the database and revoke from all users.