mirror of
https://github.com/wassname/flask-security.git
synced 2026-08-06 13:10:25 +08:00
Doc polish and such
This commit is contained in:
@@ -3,6 +3,14 @@ Flask-Security Changelog
|
||||
|
||||
Here you can see the full list of changes between each Flask-Security release.
|
||||
|
||||
Version 1.2.1
|
||||
-------------
|
||||
|
||||
Released March 28th, 2012
|
||||
|
||||
- Added optional user model mixin parameter for datastores
|
||||
- Added CreateRoleCommand to available Flask-Script commands
|
||||
|
||||
Version 1.2.0
|
||||
-------------
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ Contents
|
||||
* :ref:`overview`
|
||||
* :ref:`installation`
|
||||
* :ref:`getting-started`
|
||||
* :ref:`additional-user-fields`
|
||||
* :ref:`flask-script-commands`
|
||||
* :ref:`api`
|
||||
* :doc:`Changelog </changelog>`
|
||||
@@ -153,6 +154,22 @@ specific role::
|
||||
{$ endif %}
|
||||
|
||||
|
||||
.. _additional-user-fields:
|
||||
|
||||
Additional User Fields
|
||||
----------------------
|
||||
If you'd like to add additional fields to the user model you can use a mixin
|
||||
class that specifies your additional fields. The following is an example of
|
||||
how you might do this::
|
||||
|
||||
db = SQLAlchemy(app)
|
||||
|
||||
class UserAccountMixin():
|
||||
first_name = db.Column(db.String(120))
|
||||
last_name = db.Column(db.String(120))
|
||||
|
||||
Security(app, SQLAlchemyUserDatastore(db, UserAccountMixin))
|
||||
|
||||
.. _flask-script-commands:
|
||||
|
||||
Flask-Script Commands
|
||||
@@ -160,6 +177,7 @@ Flask-Script Commands
|
||||
Flask-Security comes packed with a few Flask-Script commands. They are:
|
||||
|
||||
* :class:`flask.ext.security.script.CreateUserCommand`
|
||||
* :class:`flask.ext.security.script.CreateRoleCommand`
|
||||
* :class:`flask.ext.security.script.AddRoleCommand`
|
||||
* :class:`flask.ext.security.script.RemoveRoleCommand`
|
||||
* :class:`flask.ext.security.script.DeactivateUserCommand`
|
||||
@@ -236,9 +254,11 @@ Datastores
|
||||
|
||||
.. autoclass:: flask_security.datastore.sqlalchemy.SQLAlchemyUserDatastore
|
||||
:members:
|
||||
:inherited-members:
|
||||
|
||||
.. autoclass:: flask_security.datastore.mongoengine.MongoEngineUserDatastore
|
||||
:members:
|
||||
:inherited-members:
|
||||
|
||||
|
||||
Models
|
||||
|
||||
@@ -19,8 +19,10 @@ class UserDatastore(object):
|
||||
:attr:`_do_find_user`, and :attr:`_do_find_role` methods.
|
||||
|
||||
:param db: An instance of a configured databse manager from a Flask
|
||||
extension such as Flask-SQLAlchemy or Flask-MongoEngine"""
|
||||
|
||||
extension such as Flask-SQLAlchemy or Flask-MongoEngine
|
||||
:param user_account_mixin: An optional mixin class that specifies additional
|
||||
fields to be added to the user model
|
||||
"""
|
||||
def __init__(self, db, user_account_mixin=None):
|
||||
self.db = db
|
||||
self.user_account_mixin = user_account_mixin or object
|
||||
|
||||
@@ -46,6 +46,19 @@ class CreateUserCommand(Command):
|
||||
pprint(kwargs)
|
||||
|
||||
|
||||
class CreateRoleCommand(Command):
|
||||
"""Create a role"""
|
||||
|
||||
option_list = (
|
||||
Option('-n', '--name', dest='name', default=None),
|
||||
Option('-d', '--desc', dest='description', default=None),
|
||||
)
|
||||
|
||||
def run(self, **kwargs):
|
||||
role = user_datastore.create_role(**kwargs)
|
||||
print 'Role "%(name)s" created successfully.' % kwargs
|
||||
|
||||
|
||||
class _RoleCommand(Command):
|
||||
option_list = (
|
||||
Option('-u', '--user', dest='user_identifier'),
|
||||
|
||||
Reference in New Issue
Block a user