Skip to content

Commit

Permalink
Fixed errors with digest and Connect settings when restoring from con…
Browse files Browse the repository at this point in the history
…figuration file
  • Loading branch information
Michal Zoubek authored and ondratu committed Dec 9, 2022
1 parent dffa36d commit 7112f5d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion prusa/link/templates/wizard_credentials.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h1>Setup Credentials</h1>
</div>
</div>

{% if wizard.restored_settings %}
{% if wizard.restored_digest %}
<div>Your password is restored from your configuration file. If you want to set a new one, please fill it into the form below.</div><br/>
{% set password_placeholder = "Restored from configuration file" %}
{% endif %}
Expand Down
9 changes: 4 additions & 5 deletions prusa/link/templates/wizard_finish.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,12 @@ <h3>Printer</h3>
<div class="row">
<div class="col">
<h1>Prusa Connect</h1>
{% if wizard.restored_connect %}
<div>Your Prusa Connect settings was restored from configuration file</div>
{% else %}
<div>Prusa Connect is a web service, where you have a complete overview of all your 3D printers at all times.</br>
You can link your PrusaLink with Prusa Connect <b>now</b>, using button down below.</div>
<ul>
{% if printer.token %}
<li>Token: <span class="white">{{ printer.token }}</span></li>
{% endif %}
</ul>
{% endif %}
</div>
</div>
<!-- Connect Row End -->
Expand Down
3 changes: 2 additions & 1 deletion prusa/link/web/lib/wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def __init__(self, _app):
# auth
self.username = _app.settings.service_local.username
self.digest = None
self.restored_settings = False
self.restored_digest = False

# network
self.net_hostname = _app.settings.network.hostname
Expand All @@ -98,6 +98,7 @@ def __init__(self, _app):

# connect
self.connect_skip = False
self.restored_connect = False
self.connect_hostname = _app.settings.service_connect.hostname
self.connect_tls = _app.settings.service_connect.tls
self.connect_port = _app.settings.service_connect.port
Expand Down
17 changes: 10 additions & 7 deletions prusa/link/web/wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,25 @@ def process_connect(config):
if option == 'port':
app.wizard.connect_port = int(connect['port'])
if option == 'token':
app.wizard.connect_token = connect['token'] \
if connect['token'] else ''
if connect['token']:
app.wizard.connect_token = connect['token']
app.wizard.restored_connect = True


def process_local(config):
"""Process local section"""
local = config[LOCAL]
for option in config.options(LOCAL):
if option == 'enable':
app.wizard.enable = local['enable']
if local['enable']:
app.wizard.enable = local['enable']
if option == 'username':
app.wizard.username = local['username']
if local['username']:
app.wizard.username = local['username']
if option == 'digest':
app.wizard.digest = local['digest']
if local['digest']:
app.wizard.digest = local['digest']
app.wizard.restored_digest = True


def parse_settings(buffer):
Expand Down Expand Up @@ -196,8 +201,6 @@ def wizard_restore_post(req):
except TimeoutError as exception:
raise conditions.RequestTimeout() from exception

app.wizard.restored_settings = True

redirect('/wizard/credentials')


Expand Down

0 comments on commit 7112f5d

Please sign in to comment.