|
|
@ -24,15 +24,15 @@ from wowstash import config
|
|
|
|
def setup():
|
|
|
|
def setup():
|
|
|
|
if current_user.wallet_created:
|
|
|
|
if current_user.wallet_created:
|
|
|
|
return redirect(url_for('wallet.dashboard'))
|
|
|
|
return redirect(url_for('wallet.dashboard'))
|
|
|
|
|
|
|
|
else:
|
|
|
|
restore_form = Restore()
|
|
|
|
restore_form = Restore()
|
|
|
|
if restore_form.validate_on_submit():
|
|
|
|
if restore_form.validate_on_submit():
|
|
|
|
if current_user.wallet_created is False:
|
|
|
|
c = docker.create_wallet(current_user.id, restore_form.seed.data)
|
|
|
|
docker.create_wallet(current_user.id, restore_form.seed.data)
|
|
|
|
cache.store_data(f'restoring_{current_user.id}', 30, c)
|
|
|
|
current_user.wallet_created = True
|
|
|
|
current_user.wallet_created = True
|
|
|
|
db.session.commit()
|
|
|
|
db.session.commit()
|
|
|
|
return redirect(url_for('wallet.loading'))
|
|
|
|
return redirect(url_for('wallet.loading'))
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return redirect(url_for('wallet.dashboard'))
|
|
|
|
|
|
|
|
return render_template(
|
|
|
|
return render_template(
|
|
|
|
'wallet/setup.html',
|
|
|
|
'wallet/setup.html',
|
|
|
|
restore_form=restore_form
|
|
|
|
restore_form=restore_form
|
|
|
@ -44,6 +44,8 @@ def loading():
|
|
|
|
if current_user.wallet_connected and current_user.wallet_created:
|
|
|
|
if current_user.wallet_connected and current_user.wallet_created:
|
|
|
|
sleep(1)
|
|
|
|
sleep(1)
|
|
|
|
return redirect(url_for('wallet.dashboard'))
|
|
|
|
return redirect(url_for('wallet.dashboard'))
|
|
|
|
|
|
|
|
if current_user.wallet_created is False:
|
|
|
|
|
|
|
|
return redirect(url_for('wallet.setup'))
|
|
|
|
return render_template('wallet/loading.html')
|
|
|
|
return render_template('wallet/loading.html')
|
|
|
|
|
|
|
|
|
|
|
|
@wallet_bp.route('/wallet/dashboard')
|
|
|
|
@wallet_bp.route('/wallet/dashboard')
|
|
|
@ -116,17 +118,27 @@ def create():
|
|
|
|
docker.create_wallet(current_user.id)
|
|
|
|
docker.create_wallet(current_user.id)
|
|
|
|
current_user.wallet_created = True
|
|
|
|
current_user.wallet_created = True
|
|
|
|
db.session.commit()
|
|
|
|
db.session.commit()
|
|
|
|
|
|
|
|
return redirect(url_for('wallet.loading'))
|
|
|
|
return 'ok'
|
|
|
|
else:
|
|
|
|
|
|
|
|
return redirect(url_for('wallet.dashboard'))
|
|
|
|
|
|
|
|
|
|
|
|
@wallet_bp.route('/wallet/status')
|
|
|
|
@wallet_bp.route('/wallet/status')
|
|
|
|
@login_required
|
|
|
|
@login_required
|
|
|
|
def status():
|
|
|
|
def status():
|
|
|
|
|
|
|
|
user_vol = docker.get_user_volume(current_user.id)
|
|
|
|
|
|
|
|
restore_container = cache.get_data(f'restoring_{current_user.id}')
|
|
|
|
|
|
|
|
if restore_container:
|
|
|
|
|
|
|
|
restoring = True
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
restoring = False
|
|
|
|
data = {
|
|
|
|
data = {
|
|
|
|
'created': current_user.wallet_created,
|
|
|
|
'created': current_user.wallet_created,
|
|
|
|
'connected': current_user.wallet_connected,
|
|
|
|
'connected': current_user.wallet_connected,
|
|
|
|
'port': current_user.wallet_port,
|
|
|
|
'port': current_user.wallet_port,
|
|
|
|
'container': current_user.wallet_container
|
|
|
|
'container': current_user.wallet_container,
|
|
|
|
|
|
|
|
'volume': docker.volume_exists(user_vol),
|
|
|
|
|
|
|
|
'restoring': restoring,
|
|
|
|
|
|
|
|
'restore_container': restore_container
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return jsonify(data)
|
|
|
|
return jsonify(data)
|
|
|
|
|
|
|
|
|
|
|
|