diff --git a/user_managment/app.py b/user_managment/app.py index 2814c91..8876ca2 100644 --- a/user_managment/app.py +++ b/user_managment/app.py @@ -88,12 +88,11 @@ class ConfigClass(object): # Flask-User settings USER_APP_NAME = title # Shown in and email templates and page footers - USER_ENABLE_EMAIL = False # Disable email authentication - USER_ENABLE_USERNAME = True # Enable username authentication - USER_REQUIRE_RETYPE_PASSWORD = True # Simplify register form - USER_ENABLE_CHANGE_USERNAME = False + USER_EMAIL_SENDER_EMAIL = MAIL_DEFAULT_SENDER + + # Setup Flask-User def create_app(): """ Flask application factory """ @@ -120,7 +119,8 @@ def create_app(): username = db.Column(db.String(100, collation='NOCASE'), nullable=False, unique=True) password = db.Column(db.String(255), nullable=False, server_default='') email_confirmed_at = db.Column(db.DateTime()) - + email = db.Column(db.String(255, collation='NOCASE'), nullable=False, unique=True) + # User information first_name = db.Column(db.String(100, collation='NOCASE'), nullable=False, server_default='') last_name = db.Column(db.String(100, collation='NOCASE'), nullable=False, server_default='') @@ -152,6 +152,7 @@ def create_app(): if not User.query.filter(User.username == 'admin').first(): user = User( username='admin', + email='admin@no.reply', email_confirmed_at=datetime.datetime.utcnow(), password=user_manager.hash_password('admin'), ) @@ -159,30 +160,6 @@ def create_app(): user.roles.append(Role(name='User')) db.session.add(user) db.session.commit() - -## from flask_user.forms import RegisterForm -## class CustomRegisterForm(RegisterForm): -## # Add a country field to the Register form -## call = StringField(('Callsign')) -## -## # Customize the User profile form: -## from flask_user.forms import EditUserProfileForm -## class CustomUserProfileForm(EditUserProfileForm): -## # Add a country field to the UserProfile form -## call = StringField(('Callsign')) -## -## # Customize Flask-User -## class CustomUserManager(UserManager): -## -## def customize(self, app): -## -## # Configure customized forms -## self.RegisterFormClass = CustomRegisterForm -## #self.UserProfileFormClass = CustomUserProfileForm -## # NB: assign: xyz_form = XyzForm -- the class! -## # (and not: xyz_form = XyzForm() -- the instance!) -## # Setup Flask-User and specify the User data-model - #user_manager = CustomUserManager(app, db, User) # Query radioid.net for list of DMR IDs, then add to DB @user_registered.connect_via(app) @@ -268,7 +245,7 @@ def create_app(): ## print(user_id) ## print(request.args.get('mode')) ## if request.args.get('mode') == 'generated': - print(id_dict) + #print(id_dict) content = '\n' for i in id_dict.items(): if i[1] == '': @@ -345,7 +322,7 @@ def create_app(): @login_required # User must be authenticated def list_users(): u = User.query.all() - u_list = '''
Callsign | @@ -376,6 +353,8 @@ def create_app(): ## callsign = request.form.get('callsign') ## u = User.query.filter_by(username=callsign).first() ## content = u.dmr_ids + if request.method == 'POST' and request.args.get('callsign') == None: + content = 'Not found' if request.method == 'POST' and request.args.get('callsign') and request.form.get('user_status'): user = request.args.get('callsign') #print(user) @@ -387,13 +366,15 @@ def create_app(): content = content + '''
+ + + |
@@ -487,6 +481,7 @@ def create_app(): |
Deleted user: ''' + str(u.username) + '''
\n +''' + confirm_link + '''''' + role_link + '''
@@ -651,12 +646,12 @@ def create_app(): #print(u_role) return str(u) - @app.route('/add_admin', methods=['POST', 'GET']) + @app.route('/add_user', methods=['POST', 'GET']) @roles_required('Admin') def add_admin(): if request.method == 'GET': content = ''' -