I have an existing project where I have built my models with mongoengine Documents. Now I want to implement role based access control in my project. I want to use flask-rbac with my User model, which currently looks like this:
class User(Document):
uuid = UUIDField(primary_key=True, default=Generator.generate_uuid)
name = StringField(min_length=1, max_length=100, required=True)
phone_number = StringField(min_length=10, max_length=15, required=True,
unique=True, validation=validate_phone_number)
password = StringField(required=True)
As you can see, my model User is made by inheriting Document class. But from the documents of flask-RBAC, they are using db.Model
. I am finding it hard how to incorporate RBAC by following the documentation, or maybe I am missing a very easy thing. Can anyone help me with this?
I want to implement two roles, admin and normal user.