Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/manasgarg/flask-sauth
Complete user authentication code for flask & mongodb.
https://github.com/manasgarg/flask-sauth
Last synced: 18 days ago
JSON representation
Complete user authentication code for flask & mongodb.
- Host: GitHub
- URL: https://github.com/manasgarg/flask-sauth
- Owner: manasgarg
- License: other
- Created: 2012-09-25T05:28:33.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2012-12-05T08:49:47.000Z (almost 12 years ago)
- Last Synced: 2024-07-31T22:51:28.416Z (3 months ago)
- Language: Python
- Size: 163 KB
- Stars: 13
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
flask-sauth
===========Complete user authentication code for flask & mongodb.
It builds upon the flask-login package to provide complete user login, logout,
password reset/change functionality.Usage
=====Step 1. Create a class that will represent a 'User' in your application. It
should extend flask_sauth.models.BaseUser class.```
# auth/models.pyfrom flask_sauth.models import BaseUser
class User( BaseUser):
...
```Step 2: In your application configuration, add "USER_MODEL_CLASS" and make it
point to the class path for your User class.```
app.config["USER_MODEL_CLASS"] = "auth.models.User"
```Step 3: During application initialization, reguster the flask_sauth blueprint.
```
from flask_sauth.views import auth_viewsapp.register_blueprint( auth_views)
```Step 4: Take a look at the template files in the source (for reference) and add
similar files to your templates/auth folder.User Management Commands
========================To add user management commands to your flask-script manage.py, just add the
following code snippet (to manage.py):```
import flask_sauth.commandsmanager = Manager( app)
flask_sauth.commands.add_commands( manager)
```This will add following commands to manage.py:
* add_user: for adding a user to the database.
* add_role: Add a role to a user.
* remove_role: Remove a role from a user.
* show_roles: Show the roles a user has.
* show_users: Show the list of users in the database.