A simple flask blueprint for managing users
Project description
flask_login_dictabase_blueprint
A Flask Blueprint for managing users.
Example App
from flask import Flask, render_template, flash from flask_login_dictabase_blueprint import ( bp, VerifyLogin, VerifyAdmin, NewUser, ForgotPassword, MagicLink, AddAdmin, GetUsers, GetUser, ) import flask_dictabase app = Flask('Test') app.db = flask_dictabase.Dictabase(app) app.config["SECRET_KEY"] = "randomUnguessableString" app.register_blueprint(bp) @app.route('/') def Index(): # This page is visible to anyone (logged in or not) return render_template('index.html', user=GetUser()) @app.route('/private') @VerifyLogin def Private(): # This page is only viewable to logged-in users. return render_template('private.html', user=GetUser()) AddAdmin('grant@grant-miller.com') # You can add one or more "admins" @app.route('/admin') @VerifyAdmin def Admin(): # This page is only viewable by the admins return render_template( 'admin.html', users=GetUsers(), user=GetUser(), ) @NewUser def NewUserCallback(user): # Called whenever a new user is created print('NewUserCallback(user=', user) flash(f'Welcome new user {user["email"]}') @ForgotPassword def ForgotPasswordCallback(user, forgotURL): # Called when a user request to reset their password. # You should email the forgotURL to the user print('ForgotPasswordCallback(user=', user, forgotURL) flash('Send an email with the forgotURL to the user', 'info') @MagicLink def MagicLinkCallback(user, magicLink): # Used to simplify login. Email the magicLink to the user. # If they click on the magicLink, they will be logged in. print('MagicLinkCallback(user=', user, magicLink) flash('Send an email with the magic link to the user', 'info') if __name__ == '__main__': app.run(debug=True)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for flask_login_dictabase_blueprint-1.0.8.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13761415e0a85ed6f641cfeba65aa662429f4d7e860ef79daed9f5cbb448805d |
|
MD5 | d1eabd6ba590aca129a47da2c5cddd09 |
|
BLAKE2b-256 | 4d2727f714daf11dedfebf1f4fc3bdae32546fa71752b12119747419cab04b18 |