Fixed asking for username
This commit is contained in:
		| @@ -8,7 +8,7 @@ from healthcheck import HealthCheck | ||||
| from flask_cors import CORS | ||||
|  | ||||
| from utils import Config | ||||
| from utils import health_database_status, security, user_datastore | ||||
| from utils import health_database_status, init_security_real_good | ||||
| from views import ItemView, ProfileView, UploadView, IndexView | ||||
|  | ||||
| from models import db | ||||
| @@ -39,7 +39,7 @@ app.config.from_object(Config) | ||||
|  | ||||
| health = HealthCheck() | ||||
| db.init_app(app) | ||||
| security.init_app(app, user_datastore) | ||||
| init_security_real_good(app) | ||||
| CORS(app) | ||||
|  | ||||
| for view in [ItemView, ProfileView, UploadView, IndexView]: | ||||
|   | ||||
| @@ -7,6 +7,7 @@ | ||||
|     <br> | ||||
|     <form action="{{ url_for_security('register') }}" method="POST" name="register_user_form"> | ||||
|         {{ register_user_form.hidden_tag() }} | ||||
|         {{ render_field_with_errors(register_user_form.name) }} | ||||
|         {{ render_field_with_errors(register_user_form.email) }} | ||||
|         {{ render_field_with_errors(register_user_form.password) }} | ||||
|         {% if register_user_form.password_confirm %} | ||||
|   | ||||
| @@ -1,3 +1,3 @@ | ||||
| from .healthchecks import health_database_status | ||||
| from .security import security, user_datastore | ||||
| from .security import security, init_security_real_good | ||||
| from .config import Config | ||||
| @@ -1,5 +1,11 @@ | ||||
| #!/usr/bin/env python3 | ||||
|  | ||||
| from flask_security import Security, SQLAlchemyUserDatastore | ||||
| from flask_security.forms import RegisterForm, Required | ||||
| from wtforms import StringField | ||||
|  | ||||
| from models import db, User, Role | ||||
|  | ||||
| """ | ||||
| Flask-Security | ||||
| """ | ||||
| @@ -9,9 +15,14 @@ __copyright__ = "Copyright 2020, UnstableVortex Team" | ||||
| __module_name__ = "security" | ||||
| __version__text__ = "1" | ||||
|  | ||||
| from flask_security import Security, SQLAlchemyUserDatastore | ||||
|  | ||||
| from models import db, User, Role | ||||
| class ExtendedRegisterForm(RegisterForm): | ||||
|     name = StringField('Username', [Required()]) | ||||
|  | ||||
|  | ||||
| user_datastore = SQLAlchemyUserDatastore(db, User, Role) | ||||
| security = Security() | ||||
| security = Security()  # Will be initiated at init_app | ||||
|  | ||||
|  | ||||
| def init_security_real_good(app): | ||||
|     security.init_app(app, datastore=user_datastore, register_form=ExtendedRegisterForm) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user