Update logout route to use logout API as HTTP request.

This commit is contained in:
Dita Aji Pratama 2025-08-05 17:34:33 +07:00
parent c08e62263b
commit e4fdbd81b0

View File

@ -6,9 +6,10 @@
# You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
from bottle import Bottle, route, request, response, redirect
from config import directory
from config import directory, globalvar
import json
import requests
import templates.plain.main as template_public
import templates.postcard.main as template_email
@ -99,8 +100,14 @@ def index():
"jwt" : beaker_session["token"],
"type" : "out"
}
response_session = api_auth.auth().session(params)
response_logout = api_auth.auth().logout(params)
print("Remove token from database")
requests_headers = {
"Authorization": f"Bearer {params['jwt']}"
}
requests_callback = requests.post(f'{globalvar.baseurl}/api/auth/logout', headers=requests_headers)
response_logout = requests_callback.json()
print("Remove token from beaker")
response_session = api_auth.auth().session(params)
if response_session['status'] == 'success' and response_logout['status'] == 'success' :
redirect('/?message=logout success')
else: