GithubHelp home page GithubHelp logo

Basic rights/roles about fublog HOT 1 CLOSED

michael-fuchs avatar michael-fuchs commented on July 25, 2024
Basic rights/roles

from fublog.

Comments (1)

floscher avatar floscher commented on July 25, 2024

@fumiX/entwickler We have the basic set of permissions as described above:

export type UserRolePermissionsType = {
/**
* This is `true` when the user is allowed to give any user additional permissions,
* and also remove their current permissions. Otherwise: `false`.
*/
canEditUserRoles: boolean;
/**
* This is `true` when the user is allowed to create a new blogpost.
* They are additionally allowed to edit those posts, which they created themselves.
* Otherwise: `false`.
*/
canCreatePost: boolean;
/**
* This is `true` when the user is allowed to edit any blogpost. Otherwise: `false`.
*/
canEditPost: boolean;
/**
* This is `true` when the user is allowed to delete any blogpost. Otherwise: `false`.
*/
canDeletePost: boolean;
};

At the moment we also have four roles that each give the user exactly one of these four permissions:

export const UserRoles: UserRolesType = {
ADMIN: new UserRolePermissions(
"Can change roles of all users", //
{ canEditUserRoles: true },
),
POST_CREATE: new UserRolePermissions(
"Can create a new post and also edit their own posts", //
{ canCreatePost: true },
),
POST_EDIT: new UserRolePermissions(
"Can edit any existing post", //
{ canEditPost: true },
),
POST_DELETE: new UserRolePermissions(
"Can delete any existing post", //
{ canDeletePost: true },
),
} as const;

Now these roles were just meant as a placeholder for a more sensible set of roles. I'd propose these ones:

  • Admin: all permissions (as soon as a user has canEditUserRoles, they could assign themselves any other role anyway)
  • Writer: canCreatePost
  • Editor: canEditPost, canDeletePost

Any comments on this, or other suggestions?


Sidenote: The concept for saving is as follows: In the user table an array of roles is persisted for each user. Both client and server are (without network calls) capable of converting a set of roles into a permission object, which has boolean attributes for what a user with that combination of roles is allowed to do.

from fublog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.