Update logout route to use logout API as HTTP request.
This commit is contained in:
parent
c08e62263b
commit
e4fdbd81b0
13
handler.py
13
handler.py
@ -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/.
|
# 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 bottle import Bottle, route, request, response, redirect
|
||||||
from config import directory
|
from config import directory, globalvar
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import requests
|
||||||
|
|
||||||
import templates.plain.main as template_public
|
import templates.plain.main as template_public
|
||||||
import templates.postcard.main as template_email
|
import templates.postcard.main as template_email
|
||||||
@ -99,8 +100,14 @@ def index():
|
|||||||
"jwt" : beaker_session["token"],
|
"jwt" : beaker_session["token"],
|
||||||
"type" : "out"
|
"type" : "out"
|
||||||
}
|
}
|
||||||
response_session = api_auth.auth().session(params)
|
print("Remove token from database")
|
||||||
response_logout = api_auth.auth().logout(params)
|
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' :
|
if response_session['status'] == 'success' and response_logout['status'] == 'success' :
|
||||||
redirect('/?message=logout success')
|
redirect('/?message=logout success')
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user