gouthambs/Flask-Blogging

Blog Roles example not working

gabriel4649 opened this issue · 2 comments

Hello! First of all thank you for making this wonderful extension.

I have been trying to getBLOGGING_PERMISSIONS=True without much luck. In the process I realized that the example https://github.com/gouthambs/Flask-Blogging/blob/master/example/blog_roles.py has BLOGGING_PERMISSIONS=False . Could you please expand the example? In particular I am wondering about the roles in the User model.

@tatsuhirosatou I just tested the blog_roles example and it is working. It would help if you could explain what was not working at your end. Here is what I did:

  • Set app.config["BLOGGING_PERMISSIONS"] = True. The blogger will be able to add new post etc.
  • Now if you comment out line 38 identity.provides.add(RoleNeed("blogger")) in the on_identity_loaded
    method, you will see that even when you login, you will not be able to edit.

So basically to give blogging control to your users, you just have to set the RoleNeed("blogger") on the identity. Preferably, you should have a database table for roles and load users role and set accordingly. Hopefully this helps.

@gouthambs Thank for your reply. It seems the problem is on my side. I will re-open the issue if I do find a bug.