Skip to content

Commit

Permalink
set APPLICATION_ROOT parameter from URL_APPLICATION
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoLechemia committed Oct 10, 2023
1 parent 36321af commit 7d0dc69
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions backend/geonature/utils/config_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import os

from urllib.parse import urlsplit

from marshmallow import (
Schema,
fields,
Expand Down Expand Up @@ -590,3 +592,13 @@ def insert_module_config(self, data, **kwargs):
continue
data[module_code] = get_module_config(dist)
return data

@post_load
def infer_application_root(self, data, **kwargs):
"""
Determine APPLICATION_ROOT from URL_APPLICATION
The parameter APPLICATION_ROOT is used by Flask tu set the cookie path (use by Flask-Login for Flask Admin)
"""
split_url = urlsplit(data["URL_APPLICATION"])
data["APPLICATION_ROOT"] = split_url.path if split_url.path else "/"
return data

0 comments on commit 7d0dc69

Please sign in to comment.