authentication - Best way to implement ban system for rails app -
i'm using devise cancan authentication in rails app , i'd able block accounts , prevent users registering blocked email , phone. i'm not sure best way this.
i have roles: admin, moderator, , user admin: must have ability ban/block moderators, , users moderator: must have ability ban/block users
my first thought add new 'blocked' role, think there better way.
i go simplest way : boolean "blocked" on user table. define :
class user def block(other_user) if(can_block? other_user) other_user.block = true other_user.save! end end def can_block?(other_user) # logic using roles. end end
straightforward, way.
Comments
Post a Comment