/yunohost/sso/log{in,out} 303 to referer when GET/POST param referer_redirect is set

This commit is contained in:
selfhoster1312 2023-08-14 22:00:28 +02:00
parent a6c7e55d1d
commit e24d56d5f1

View file

@ -13,7 +13,7 @@ from gevent import sleep
from gevent.queue import Queue from gevent.queue import Queue
from geventwebsocket import WebSocketError from geventwebsocket import WebSocketError
from bottle import request, response, Bottle, HTTPResponse, FileUpload from bottle import redirect, request, response, Bottle, HTTPResponse, FileUpload
from bottle import abort from bottle import abort
from moulinette import m18n, Moulinette from moulinette import m18n, Moulinette
@ -380,6 +380,10 @@ class _ActionsMapPlugin:
raise HTTPResponse(e.strerror, 401) raise HTTPResponse(e.strerror, 401)
else: else:
authenticator.set_session_cookie(auth_infos) authenticator.set_session_cookie(auth_infos)
referer = request.get_header("Referer")
if "referer_redirect" in request.params and referer:
redirect(referer)
else:
return m18n.g("logged_in") return m18n.g("logged_in")
# This is called before each time a route is going to be processed # This is called before each time a route is going to be processed
@ -404,7 +408,11 @@ class _ActionsMapPlugin:
else: else:
# Delete cookie and clean the session # Delete cookie and clean the session
authenticator.delete_session_cookie() authenticator.delete_session_cookie()
return m18n.g("logged_out") referer = request.get_header("Referer")
if "referer_redirect" in request.params and referer:
redirect(referer)
else:
return m18n.g("logged_in")
def messages(self): def messages(self):
"""Listen to the messages WebSocket stream """Listen to the messages WebSocket stream