mirror of
https://github.com/andwati/predictive_analysis.git
synced 2026-10-24 19:02:17 +00:00
implemented auth
This commit is contained in:
@@ -14,6 +14,7 @@ sys.path.append(str(src_path))
|
||||
from src.config.theme import ROSE_PINE_THEME, PAGE_CONFIG, APP_TITLE, APP_SUBTITLE
|
||||
from src.config.mappings import create_feature_mappings
|
||||
from src.utils.model_utils import load_model_and_info
|
||||
from src.utils.auth import require_auth, check_role_permission, render_admin_panel, check_session_timeout
|
||||
from src.components.form_components import (
|
||||
render_preset_selector,
|
||||
render_personal_info_section,
|
||||
@@ -77,10 +78,11 @@ def collect_user_input():
|
||||
|
||||
return user_input
|
||||
|
||||
@require_auth
|
||||
def main():
|
||||
"""Main Streamlit application"""
|
||||
# Configure page
|
||||
st.set_page_config(**PAGE_CONFIG)
|
||||
# Check session timeout (30 minutes)
|
||||
check_session_timeout(30)
|
||||
|
||||
# Apply theme
|
||||
apply_theme()
|
||||
@@ -88,9 +90,14 @@ def main():
|
||||
# Load model and preprocessing info
|
||||
model, preprocessing_info, feature_names = load_model_and_info()
|
||||
|
||||
# Render header
|
||||
# Render header with user context
|
||||
render_header()
|
||||
|
||||
# Add admin panel if user is admin
|
||||
if check_role_permission("admin"):
|
||||
with st.sidebar:
|
||||
render_admin_panel()
|
||||
|
||||
# Collect user input
|
||||
user_input = collect_user_input()
|
||||
|
||||
@@ -100,6 +107,10 @@ def main():
|
||||
with col1:
|
||||
st.markdown('<h2 class="sub-header">Prediction Results</h2>', unsafe_allow_html=True)
|
||||
|
||||
# Add role-based access message
|
||||
if check_role_permission("educator"):
|
||||
st.markdown('<div class="info-box">🎓 <strong>Educator Access:</strong> You have full access to prediction features and student data analysis.</div>', unsafe_allow_html=True)
|
||||
|
||||
# Render prediction section
|
||||
render_prediction_section(model, preprocessing_info, user_input)
|
||||
|
||||
@@ -107,11 +118,16 @@ def main():
|
||||
# Render model info and validation
|
||||
render_model_info_sidebar(user_input)
|
||||
|
||||
# Render export section
|
||||
render_export_section(user_input)
|
||||
# Render export section (role-based access)
|
||||
if check_role_permission("educator"):
|
||||
render_export_section(user_input)
|
||||
else:
|
||||
st.markdown('<div class="warning-box">📊 <strong>Export Feature:</strong> Available for educators and administrators only.</div>', unsafe_allow_html=True)
|
||||
|
||||
# Render footer
|
||||
render_footer()
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Configure page before authentication
|
||||
st.set_page_config(**PAGE_CONFIG)
|
||||
main()
|
||||
Reference in New Issue
Block a user