🐛 Fix first run setup
This commit is contained in:
1 parent
60d2bd1ac1
commit
de0b97b99c
3 files changed
+9
-5
No files matched your search
@@ -7,7 +7,7 @@ __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms
|
||||
|
||||
import logging
|
||||
|
||||
from flask import request, jsonify, make_response
|
||||
from flask import request, jsonify, make_response, abort
|
||||
from flask_login import current_user
|
||||
from werkzeug.exceptions import BadRequest
|
||||
|
||||
@@ -73,11 +73,13 @@ def _etag(lm=None):
|
||||
return hash.hexdigest()
|
||||
|
||||
@api.route("/settings", methods=["GET"])
|
||||
@Permissions.SETTINGS_READ.require(403)
|
||||
@with_revalidation_checking(etag_factory=_etag,
|
||||
lastmodified_factory=_lastmodified,
|
||||
unless=lambda: request.values.get("force", "false") in valid_boolean_trues)
|
||||
unless=lambda: request.values.get("force", "false") in valid_boolean_trues or settings().getBoolean(["server", "firstRun"]))
|
||||
def getSettings():
|
||||
if not Permissions.SETTINGS_READ.can() and not settings().getBoolean(["server", "firstRun"]):
|
||||
abort(403)
|
||||
|
||||
s = settings()
|
||||
|
||||
connectionOptions = printer.__class__.get_connection_options()
|
||||
|
||||
@@ -411,7 +411,9 @@ def index():
|
||||
return util.flask.add_non_caching_response_headers(make_response(render_template("forcelogin.jinja2")))
|
||||
|
||||
def default_view():
|
||||
if request.headers.get("X-Preemptive-Record", None) == "no" or (Permissions.STATUS.can() and Permissions.SETTINGS_READ.can()):
|
||||
if request.headers.get("X-Preemptive-Record", None) == "no" \
|
||||
or (Permissions.STATUS.can() and Permissions.SETTINGS_READ.can()) \
|
||||
or settings().getBoolean(["server", "firstRun"]):
|
||||
return ui_view()
|
||||
else:
|
||||
return login_view()
|
||||
|
||||
@@ -41,7 +41,7 @@ $(function() {
|
||||
};
|
||||
|
||||
self.onUserLoggedOut = self.onUserPermissionsChanged = function() {
|
||||
if (!self.loginState.hasAllPermissions(self.access.permissions.STATUS, self.access.permissions.SETTINGS_READ)) {
|
||||
if (!self.loginState.hasAllPermissions(self.access.permissions.STATUS, self.access.permissions.SETTINGS_READ) && !CONFIG_FIRST_RUN) {
|
||||
location.reload();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user