mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Merge pull request #339 from selfhoster1312/redirect-referer
portal-api: login/logout redirect to referer when param referer_redirect is set
This commit is contained in:
commit
6f09185a70
1 changed files with 11 additions and 3 deletions
|
@ -13,7 +13,7 @@ from gevent import sleep
|
|||
from gevent.queue import Queue
|
||||
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 moulinette import m18n, Moulinette
|
||||
|
@ -381,6 +381,10 @@ class _ActionsMapPlugin:
|
|||
raise HTTPResponse(e.strerror, 401)
|
||||
else:
|
||||
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")
|
||||
|
||||
# This is called before each time a route is going to be processed
|
||||
|
@ -405,7 +409,11 @@ class _ActionsMapPlugin:
|
|||
else:
|
||||
# Delete cookie and clean the session
|
||||
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):
|
||||
"""Listen to the messages WebSocket stream
|
||||
|
|
Loading…
Reference in a new issue