diff --git a/paramecio/citoplasma/urls.py b/paramecio/citoplasma/urls.py index 27a9c18..16bed9a 100644 --- a/paramecio/citoplasma/urls.py +++ b/paramecio/citoplasma/urls.py @@ -1,6 +1,20 @@ #!/usr/bin/python3 from settings import config +from bottle import request, response, HTTPResponse + +# A modified version of bottle url for don't need set x-proxy shit for redirect... + +def redirect(url, code=None): + """ Aborts execution and causes a 303 or 302 redirect, depending on + the HTTP protocol version. """ + if not code: + code = 303 if request.get('SERVER_PROTOCOL') == "HTTP/1.1" else 302 + res = response.copy(cls=HTTPResponse) + res.status = code + res.body = "" + res.set_header('Location', url) + raise res #Simple method for make urls diff --git a/paramecio/modules/admin/index.py b/paramecio/modules/admin/index.py index 9a889b0..1a0e860 100644 --- a/paramecio/modules/admin/index.py +++ b/paramecio/modules/admin/index.py @@ -4,7 +4,7 @@ import traceback, sys from paramecio.citoplasma.mtemplates import env_theme, PTemplate from paramecio.modules.admin.models.admin import UserAdmin from paramecio.citoplasma.i18n import load_lang, I18n -from paramecio.citoplasma.urls import make_url, add_get_parameters +from paramecio.citoplasma.urls import make_url, add_get_parameters, redirect from paramecio.citoplasma.sessions import get_session, generate_session from bottle import get,post,response,request from settings import config @@ -17,7 +17,6 @@ from paramecio.cromosoma.formsutils import show_form, pass_values_to_form, set_e from paramecio.cromosoma.coreforms import PasswordForm from paramecio.cromosoma.webmodel import WebModel from importlib import import_module, reload -from bottle import redirect from collections import OrderedDict from time import time from paramecio.citoplasma.keyutils import create_key_encrypt, create_key_encrypt_256, create_key @@ -165,7 +164,7 @@ def home(module='', submodule=''): s['login']=1 s['privileges']=arr_user['privileges'] - redirect('/'+config.admin_folder) + redirect(make_url(config.admin_folder)) else: @@ -369,7 +368,7 @@ def logout(): #return "" - redirect('/'+config.admin_folder) + redirect(make_url(config.admin_folder)) @get('/'+config.admin_folder+'/recovery_password') def recovery_password():