From f2e41174a7e2091e7e835b137c6c7e2874feda04 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 23 Aug 2013 17:38:55 -0500 Subject: Finally figured out where to put flask_security into the code Various registration template changes --- wqflask/flask_security/__init__.py | 4 ++-- wqflask/secure_server.py | 3 +++ wqflask/wqflask/model.py | 14 +++++++++++++- wqflask/wqflask/templates/admin/ind_user_manager.html | 10 ++++++++++ wqflask/wqflask/templates/security/register_user.html | 16 +++++++++++++++- 5 files changed, 43 insertions(+), 4 deletions(-) diff --git a/wqflask/flask_security/__init__.py b/wqflask/flask_security/__init__.py index 297033c9..81e6c89e 100644 --- a/wqflask/flask_security/__init__.py +++ b/wqflask/flask_security/__init__.py @@ -12,8 +12,6 @@ __version__ = '1.6.0' -print "using internal flask security" - from .core import Security, RoleMixin, UserMixin, AnonymousUser, current_user from .datastore import SQLAlchemyUserDatastore, MongoEngineUserDatastore, PeeweeUserDatastore from .decorators import auth_token_required, http_auth_required, \ @@ -23,3 +21,5 @@ from .forms import ForgotPasswordForm, LoginForm, RegisterForm, \ from .signals import confirm_instructions_sent, password_reset, \ reset_password_instructions_sent, user_confirmed, user_registered from .utils import login_user, logout_user, url_for_security + +print "Using our own flask.ext.security" \ No newline at end of file diff --git a/wqflask/secure_server.py b/wqflask/secure_server.py index 2abfdb05..04b85663 100644 --- a/wqflask/secure_server.py +++ b/wqflask/secure_server.py @@ -25,6 +25,9 @@ app.logger.addHandler(file_handler) import logging_tree logging_tree.printout() +import sys +print("At startup, path is:", sys.path) + #print("app.config is:", app.config) if __name__ == '__main__': diff --git a/wqflask/wqflask/model.py b/wqflask/wqflask/model.py index 5beba9ff..1f873545 100644 --- a/wqflask/wqflask/model.py +++ b/wqflask/wqflask/model.py @@ -3,6 +3,9 @@ from __future__ import print_function, division, absolute_import from flask.ext.sqlalchemy import SQLAlchemy from flask.ext.security import Security, SQLAlchemyUserDatastore, UserMixin, RoleMixin +from flask_security.forms import TextField +from flask_security.forms import RegisterForm + from wqflask import app # Create database connection object @@ -46,6 +49,10 @@ class User(db.Model, UserMixin): id = db.Column(db.Integer(), primary_key=True) email = db.Column(db.String(255), unique=True) password = db.Column(db.String(255)) + + name = db.Column(db.Unicode(255)) + organization = db.Column(db.Unicode(255)) + active = db.Column(db.Boolean()) confirmed_at = db.Column(db.DateTime()) @@ -60,7 +67,12 @@ class User(db.Model, UserMixin): # Setup Flask-Security user_datastore = SQLAlchemyUserDatastore(db, User, Role) -security = Security(app, user_datastore) + +class ExtendedRegisterForm(RegisterForm): + name = TextField('name') + organization = TextField('organization') + +security = Security(app, user_datastore, register_form=ExtendedRegisterForm) db.metadata.create_all(db.engine) diff --git a/wqflask/wqflask/templates/admin/ind_user_manager.html b/wqflask/wqflask/templates/admin/ind_user_manager.html index 9776af0b..2fe4a002 100644 --- a/wqflask/wqflask/templates/admin/ind_user_manager.html +++ b/wqflask/wqflask/templates/admin/ind_user_manager.html @@ -30,6 +30,16 @@