Fixed asking for username
This commit is contained in:
parent
c8b491bd0b
commit
7f513d05b2
@ -8,7 +8,7 @@ from healthcheck import HealthCheck
|
|||||||
from flask_cors import CORS
|
from flask_cors import CORS
|
||||||
|
|
||||||
from utils import Config
|
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 views import ItemView, ProfileView, UploadView, IndexView
|
||||||
|
|
||||||
from models import db
|
from models import db
|
||||||
@ -39,7 +39,7 @@ app.config.from_object(Config)
|
|||||||
|
|
||||||
health = HealthCheck()
|
health = HealthCheck()
|
||||||
db.init_app(app)
|
db.init_app(app)
|
||||||
security.init_app(app, user_datastore)
|
init_security_real_good(app)
|
||||||
CORS(app)
|
CORS(app)
|
||||||
|
|
||||||
for view in [ItemView, ProfileView, UploadView, IndexView]:
|
for view in [ItemView, ProfileView, UploadView, IndexView]:
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
<br>
|
<br>
|
||||||
<form action="{{ url_for_security('register') }}" method="POST" name="register_user_form">
|
<form action="{{ url_for_security('register') }}" method="POST" name="register_user_form">
|
||||||
{{ register_user_form.hidden_tag() }}
|
{{ 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.email) }}
|
||||||
{{ render_field_with_errors(register_user_form.password) }}
|
{{ render_field_with_errors(register_user_form.password) }}
|
||||||
{% if register_user_form.password_confirm %}
|
{% if register_user_form.password_confirm %}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
from .healthchecks import health_database_status
|
from .healthchecks import health_database_status
|
||||||
from .security import security, user_datastore
|
from .security import security, init_security_real_good
|
||||||
from .config import Config
|
from .config import Config
|
@ -1,5 +1,11 @@
|
|||||||
#!/usr/bin/env python3
|
#!/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
|
Flask-Security
|
||||||
"""
|
"""
|
||||||
@ -9,9 +15,14 @@ __copyright__ = "Copyright 2020, UnstableVortex Team"
|
|||||||
__module_name__ = "security"
|
__module_name__ = "security"
|
||||||
__version__text__ = "1"
|
__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)
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user