Разграничение прав на использование разделов

This commit is contained in:
Anton Kamalov
2024-10-25 11:37:41 +03:00
parent f708df717c
commit 36688b318d
8 changed files with 39 additions and 17 deletions

View File

@@ -1,15 +1,10 @@
from flask import request, Blueprint, render_template, session, redirect, url_for
from flask import request, Blueprint, render_template, session, current_app,redirect, url_for
import os
from .auth_route import route
from Database.sql_provider import SQLProvider
import json
sql_provider = SQLProvider(os.path.join(os.path.dirname(__file__), 'sql'))
auth_bp = Blueprint('auth_bp', __name__, template_folder='templates')
db_config_path = os.path.join(os.path.dirname(__file__), os.pardir, 'Database/config.json')
with open(db_config_path) as f:
config = json.load(f)
@auth_bp.route('/', methods=['GET', 'POST'])
def auth():
@@ -17,12 +12,12 @@ def auth():
return render_template('auth.html')
else:
data = request.form.to_dict()
auth_data = route(config, data, sql_provider, 'auth.sql')
auth_data = route(current_app.config['db_config'], data, sql_provider, 'auth.sql')
if auth_data.status:
session.update({
'login': auth_data.result[0]['login'],
'role': auth_data.result[0]['role'],
'db_config': config,
'db_config': current_app.config['db_config'],
'permanent': True
})
return redirect(url_for('index'))