mal-wtag / stackoverflow_with_drupal

This will be a sample project with Drupal to introduce new members with Drupal and also to get experiences
MIT License
0 stars 0 forks source link

Investigation: Create user authentication using Drupal user manager #4

Open zar-wtag opened 4 years ago

zar-wtag commented 4 years ago

Background

Our Stackoverflow clone will need different kind of roles and permissions. At the moment we don't know exactly what Stackoverflow has and how we could implement that.

Goal

Investigate what kind of roles and permissions Stackoverflow uses and investigate how we could implement it in our project.

Acceptance

luxflux commented 4 years ago

Report

What does StackOverflow have?

StackOverflow uses a tier based permission model. See this page for the different tiers and permissions.

How can we replicate it using Drupal?

Having roles and different permissions for them is a basic Drupal thing. The one thing not available is the automatic switch between the roles.

Roles & Permissions

This is based on the following documentations:

Roles

I'd keep things a bit simpler and only work with 5 roles:

Permissions

Permissions can be configured at /admin/people/permissions.

Role: User
Role: Commentator
Role: Moderator

Automatic Promotion

To implement the automatic promotion, we'll have to create a module with a hook. See this example module to get started.

To keep things simple (in a first version at least), I'd suggest to automatically promote users based on their actions. For example:

Drupal has the hook hook_entity_insert or hook_ENTITY_TYPE_insert which we can use to check if a user should be promoted.

Inside the hook, the following things should happen: