Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing a Suspension or Penalty System for Users in ASP.NET MVC

I'm writing a site in ASP.NET MVC that will have user accounts. As the site will be oriented towards discussion, I think I need a system for admins to be able to moderate users, just like we have here, on Stack Overflow. I'd like to be able to put a user into a "suspension", so that they are able to log in to the site (at which point they are greeted with a message, such as, "Your account has been suspended until [DATE]"), but are unable to do the functions that users they would normally be able to do.

What's the best way of implementing this?

I was thinking of creating a "Suspended" role, but the thing is, I have a few different roles for normal users themselves, with different privileges.

Have you ever designed a feature like this before? How should I do it? Thanks in advance.

like image 236
Maxim Zaslavsky Avatar asked Apr 17 '10 05:04

Maxim Zaslavsky


1 Answers

I think roles is the way to go without writing lots of plumbing code.

Create a role called Active which everyone is a member of by default. Then take users out of that role while they are suspended.

Every action you want to deny to suspended users requires the Active role. Simples.

like image 81
James Westgate Avatar answered Oct 10 '22 03:10

James Westgate