From 9646452457a77bc74bbb0ef0144fd6f0a8ecdc48 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Wed, 28 Jul 2021 09:42:22 +0300 Subject: [PATCH] redirige vers formulaire authentification --- README.md | 1 - app/auth/routes.py | 1 + app/decorators.py | 5 +++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 201f42c3d..06f0ae400 100644 --- a/README.md +++ b/README.md @@ -185,7 +185,6 @@ Principaux contenus: # TODO - - redirection pour authentification - import/export Excel diff --git a/app/auth/routes.py b/app/auth/routes.py index b45e05c2f..410c5f43d 100644 --- a/app/auth/routes.py +++ b/app/auth/routes.py @@ -4,6 +4,7 @@ auth.routes.py """ from flask import render_template, redirect, url_for, current_app, flash, request +from flask_login.utils import login_required from werkzeug.urls import url_parse from flask_login import login_user, logout_user, current_user diff --git a/app/decorators.py b/app/decorators.py index 846c29153..412b59405 100644 --- a/app/decorators.py +++ b/app/decorators.py @@ -108,11 +108,12 @@ def permission_required(permission): # current_app.logger.info( # "permission_required: %s in %s" % (permission, g.scodoc_dept) # ) - if not current_user.has_permission(permission, g.scodoc_dept): + scodoc_dept = getattr(g, "scodoc_dept", None) + if not current_user.has_permission(permission, scodoc_dept): abort(403) return f(*args, **kwargs) - return decorated_function + return login_required(decorated_function) return decorator