# Path: mass_flask_config/app.py
# BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# SECRET_FILE = os.path.join(BASE_DIR, 'secret.txt')
# def setup_session_auth(user_loader):
# def setup_key_based_auth(key_loader):
# def unauthorized_callback():
# 
# Path: mass_flask_webui/config.py

# 
# Path: mass_flask_webui/forms/login.py
# class LoginForm(Form):
#     username = StringField(validators=[DataRequired()])
#     password = PasswordField(validators=[DataRequired()])
#     submit = SubmitField()
# 
#     def __init__(self, *args, **kwargs):
#         super().__init__(*args, **kwargs)
#         self.user = None
# 
#     def validate(self, extra_validators=None):
#         if not super(LoginForm, self).validate():
#             return False
#         user = User.user_loader(username=self.data['username'], password=self.data['password'])
#         if not user:
#             flash('Username/password incorrect.', 'warning')
#             return False
#         else:
#             self.user = user
#             return True


from flask import flash, render_template, redirect, url_for
from flask_modular_auth import current_authenticated_entity, privilege_required, RolePrivilege
from mass_flask_config.app import app
from mass_flask_webui.config import webui_blueprint
from mass_flask_webui.forms.login import LoginForm



@webui_blueprint.route('/login/', methods=['GET', 'POST'])
def login():
    if current_authenticated_entity.is_authenticated:
        return redirect(url_for('.profile'))
    else:

# Path: mass_flask_config/app.py
# BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# SECRET_FILE = os.path.join(BASE_DIR, 'secret.txt')
# def setup_session_auth(user_loader):
# def setup_key_based_auth(key_loader):
# def unauthorized_callback():
# 
# Path: mass_flask_webui/config.py

# 
# Path: mass_flask_webui/forms/login.py
# class LoginForm(Form):
#     username = StringField(validators=[DataRequired()])
#     password = PasswordField(validators=[DataRequired()])
#     submit = SubmitField()
# 
#     def __init__(self, *args, **kwargs):
#         super().__init__(*args, **kwargs)
#         self.user = None
# 
#     def validate(self, extra_validators=None):
#         if not super(LoginForm, self).validate():
#             return False
#         user = User.user_loader(username=self.data['username'], password=self.data['password'])
#         if not user:
#             flash('Username/password incorrect.', 'warning')
#             return False
#         else:
#             self.user = user
#             return True


# Path: mass_flask_webui/views/login.py
from flask import flash, render_template, redirect, url_for
from flask_modular_auth import current_authenticated_entity, privilege_required, RolePrivilege
from mass_flask_config.app import app
from mass_flask_webui.config import webui_blueprint
from mass_flask_webui.forms.login import LoginForm




@webui_blueprint.route('/login/', methods=['GET', 'POST'])
def login():
    if current_authenticated_entity.is_authenticated:
        return redirect(url_for('.profile'))
    else:

        form = LoginForm()