Administrators and Roles
You are reading the documentation for version 2 of FoalTS. Instructions for upgrading to this version are available here. The old documentation can be found here.
In simple applications, access control can be managed with static roles or even with an isAdmin
column in the simplest cases.
#
Admin and Non-AdminsIf there are only two categories of users, administrators and non-administrators, a simple solution is to add an isAdmin
column to the user
table. Then authorization is handled by looking at the isAdmin
property of the User
objects.
entities/user.entity.ts
hooks/admin-required.hook.ts
controllers/api.controller.ts
#
Static RolesIf it exists more than two categories and/or a user can belong to several categories then defining a roles
property can also be a solution.
entities/user.entity.ts
hooks/role-required.hook.ts
controllers/api.controller.ts