Enhance user role management and access control in the application. Added user management link in the navigation for admins. Updated login flow to redirect to Casdoor for authentication. Improved logging for user actions and unauthorized access attempts. Adjusted role checks across various views to include '管理员' and 'admin' for access permissions.
This commit is contained in:
@@ -7,7 +7,8 @@ def init_history_routes(app):
|
||||
@app.route('/history')
|
||||
@login_required
|
||||
def history():
|
||||
if current_user.role not in ['装维员', '统计员']:
|
||||
allowed_roles = ['装维员', '统计员', '管理员', 'admin']
|
||||
if current_user.role not in allowed_roles and current_user.name != 'Admin':
|
||||
app.logger.warning(f'未授权访问:用户 {current_user.name} 尝试访问历史记录')
|
||||
flash('您没有权限访问此页面')
|
||||
return redirect(url_for('statistics'))
|
||||
@@ -110,7 +111,8 @@ def init_history_routes(app):
|
||||
@app.route('/history/<string:order_id>')
|
||||
@login_required
|
||||
def history_detail(order_id):
|
||||
if current_user.role not in ['装维员', '统计员']:
|
||||
allowed_roles = ['装维员', '统计员', '管理员', 'admin']
|
||||
if current_user.role not in allowed_roles and current_user.name != 'Admin':
|
||||
app.logger.warning(f'未授权访问:用户 {current_user.name} 尝试查看工单详情 {order_id}')
|
||||
flash('您没有权限访问此页面')
|
||||
return redirect(url_for('statistics'))
|
||||
|
||||
Reference in New Issue
Block a user