Commit 1c872791 authored by iv's avatar iv

Redirect by default to flaskdav's main page (back_url is optional)

+ show accepted cookie list.
parent 6cc217e6
......@@ -323,6 +323,7 @@ def authorize():
if request.method == 'POST':
response = make_response()
debug(request.form.items())
if request.form.get('reset') == 'true':
debug('old key was: ' + app.secret_key)
generate_key()
......@@ -339,8 +340,9 @@ def authorize():
else:
return 'Something went wrong...'
if back:
response.status = '301' # moved permanently
response.headers['Location'] = '/'
if back:
response.headers['Location'] = back
# what if not? use referer? send bad request error? just do nothing?
......@@ -348,6 +350,10 @@ def authorize():
debug(request.args)
headers = request.headers
response = make_response(render_template('authorization_page.html',
cookie_list=[ base64_decode(cookey)
for cookey in
request.cookies.keys()
if verify_cookie(cookey) ],
origin=request.args.get('origin'),
back_url=request.args.get('back_url')))
return response
......
<div>Allow origin: {{ origin }} ? </div>
<div>You will then be redirected to {{ back_url }} .</div>
<div>{% if back_url %}
You will then be redirected to '{{ back_url }}'.
{% else %}
You will be redirected to the server's main page.
{% endif %}</div>
<div>
{% if cookie_list %}
List of cookies set for accepted origins until now:
<ul>
{% for cookie in cookie_list %}
<li> {{ cookie }} </li>
{% endfor %}
</ul>
{% else %}
No cookies are set.
{% endif %}
</div>
<form action="" method="post">
<input type="checkbox" name="reset" value="true"> Invalidate all previous cookies <br>
<button name="accept" value="ok">OK</button>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment