Правка проверки на пользователя + корректировка содержаний модулей
This commit is contained in:
24
App/Auth/__init__.py
Normal file
24
App/Auth/__init__.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from flask import request, Blueprint, render_template, session, current_app, redirect, url_for
|
||||
from .auth_model import auth_model
|
||||
|
||||
auth_bp = Blueprint('auth_bp', __name__, template_folder='templates')
|
||||
|
||||
@auth_bp.route('/', methods=['GET', 'POST'])
|
||||
def auth():
|
||||
if request.method == 'GET':
|
||||
return render_template('auth.html')
|
||||
else:
|
||||
data = request.form.to_dict()
|
||||
data['table'] = 'internal_users' if 'internal' in data else 'external_users'
|
||||
auth_data = auth_model(data)
|
||||
if auth_data.status:
|
||||
session.update({
|
||||
'login': auth_data.result[0]['login'],
|
||||
'role': auth_data.result[0]['user_role'],
|
||||
'db_config': current_app.config['db_config'],
|
||||
'access_user': 'in' if 'internal' in data else 'ext',
|
||||
'permanent': True
|
||||
})
|
||||
return redirect(url_for('index'))
|
||||
else:
|
||||
return render_template('error.html', error_message=auth_data.error_message)
|
||||
Reference in New Issue
Block a user