Skip to content

Commit

Permalink
Add docs to show how to set user/role model.
Browse files Browse the repository at this point in the history
  • Loading branch information
shonenada committed Apr 4, 2014
1 parent a29ede6 commit 4b43fd9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/quickstart.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ the Role class to adapt your application, here is an example::
def get_by_name(name):
return Role.query.filter_by(name=name).first()

After create role model, you can add your model to Flask-RBAC::

rbac.set_role_model(Role)

Or use decorator to set role model for Flask-RBAC::

@rbac.as_role_model
class Role(RoleMixin):
# codes go here


Set User Model
--------------
Expand Down Expand Up @@ -143,6 +153,16 @@ Well, if your application works under SQLAlchemy::
for role in self.roles:
yield role

Same as role model, you should add user model to Flask-RBAC::

rbac.set_user_model(User)

Or using decorator::

@rbac.as_user_model
class User(UserMixin):
# codes go here


Set User Loader
---------------
Expand Down

0 comments on commit 4b43fd9

Please sign in to comment.