|
|
|
@ -73,18 +73,19 @@ async def challenge(handle):
|
|
|
|
|
'address': user.wallet_address,
|
|
|
|
|
'signature': form.signature.data
|
|
|
|
|
}
|
|
|
|
|
try:
|
|
|
|
|
res = make_wallet_rpc('verify', data)
|
|
|
|
|
print(res)
|
|
|
|
|
from quart import jsonify
|
|
|
|
|
return jsonify(res)
|
|
|
|
|
# # Check if user doesn't exist
|
|
|
|
|
# user = User.select().where(
|
|
|
|
|
# User.handle == form.handle.data
|
|
|
|
|
# ).first()
|
|
|
|
|
# if not user:
|
|
|
|
|
# await flash('That handle does not exist.')
|
|
|
|
|
# return redirect(url_for('auth.login'))
|
|
|
|
|
if res['good']:
|
|
|
|
|
user.generate_challenge()
|
|
|
|
|
login_user(user)
|
|
|
|
|
await flash('Successful login!')
|
|
|
|
|
return redirect(url_for('main.index'))
|
|
|
|
|
else:
|
|
|
|
|
await flash('Invalid signature. Try again.')
|
|
|
|
|
return redirect(url_for('auth.challenge', handle=handle))
|
|
|
|
|
except Exception as e:
|
|
|
|
|
await flash(f'Issue with checking the signature provided: {e}')
|
|
|
|
|
return redirect(url_for('auth.challenge', handle=handle))
|
|
|
|
|
|
|
|
|
|
return await render_template(
|
|
|
|
|
'auth/challenge.html',
|
|
|
|
@ -99,29 +100,3 @@ async def logout():
|
|
|
|
|
else:
|
|
|
|
|
await flash('Not authenticated!')
|
|
|
|
|
return redirect(url_for('main.index'))
|
|
|
|
|
|
|
|
|
|
# @auth_bp.route("/reset/<string:hash>", methods=["GET", "POST"])
|
|
|
|
|
# def reset(hash):
|
|
|
|
|
# hash = PasswordReset.query.filter(PasswordReset.hash==hash).first()
|
|
|
|
|
# if not hash:
|
|
|
|
|
# flash('Invalid password reset hash')
|
|
|
|
|
# return redirect(url_for('auth.login'))
|
|
|
|
|
#
|
|
|
|
|
# if hash.hours_elapsed() > hash.expiration_hours or hash.expired:
|
|
|
|
|
# flash('Reset hash has expired')
|
|
|
|
|
# return redirect(url_for('auth.login'))
|
|
|
|
|
#
|
|
|
|
|
# form = ResetPassword()
|
|
|
|
|
# if form.validate_on_submit():
|
|
|
|
|
# try:
|
|
|
|
|
# user = User.query.get(hash.user)
|
|
|
|
|
# user.password = bcrypt.generate_password_hash(form.password.data).decode('utf8')
|
|
|
|
|
# hash.expired = True
|
|
|
|
|
# db.session.commit()
|
|
|
|
|
# flash('Password reset successfully')
|
|
|
|
|
# return redirect(url_for('auth.login'))
|
|
|
|
|
# except:
|
|
|
|
|
# flash('Error resetting password')
|
|
|
|
|
# return redirect(url_for('auth.login'))
|
|
|
|
|
#
|
|
|
|
|
# return render_template('auth/reset.html', form=form)
|
|
|
|
|