diff --git a/nerochan/routes/auth.py b/nerochan/routes/auth.py index 1ca448e..5623573 100644 --- a/nerochan/routes/auth.py +++ b/nerochan/routes/auth.py @@ -1,5 +1,7 @@ -from flask import Blueprint, render_template -from flask import flash, redirect, url_for +from datetime import datetime + +from flask import Blueprint, render_template, request +from flask import flash, redirect, url_for, Response from flask_login import logout_user, current_user from nerochan.forms import UserForm, UserRegistration, UserChallenge @@ -67,6 +69,14 @@ def challenge(handle): flash('Already logged in.') return redirect(url_for('main.index')) + if request.args.get('download'): + fn = int(datetime.utcnow().timestamp()) + return Response( + user.challenge, + mimetype='text/plain', + headers={'Content-Disposition': f'attachment;filename=challenge_{fn}.txt'} + ) + if form.validate_on_submit(): data = { 'data': user.challenge, diff --git a/nerochan/templates/auth/challenge.html b/nerochan/templates/auth/challenge.html index 0fd85b7..1055eb3 100644 --- a/nerochan/templates/auth/challenge.html +++ b/nerochan/templates/auth/challenge.html @@ -6,7 +6,7 @@
Handle: {{ user.handle }}
-Challenge: {{ user.challenge }}
+Challenge: {{ user.challenge }} (download)
Wallet Address: {{ user.wallet_address }}
{% include 'includes/form.html' %}