mirror of
				https://github.com/PhoenixTwoFive/karaoqueue.git
				synced 2025-11-04 01:15:11 +01:00 
			
		
		
		
	Admin credentials can be changed via settings
This commit is contained in:
		@@ -83,6 +83,9 @@ def settings_post():
 | 
				
			|||||||
    entryquota = request.form.get("entryquota")
 | 
					    entryquota = request.form.get("entryquota")
 | 
				
			||||||
    maxqueue = request.form.get("maxqueue")
 | 
					    maxqueue = request.form.get("maxqueue")
 | 
				
			||||||
    theme = request.form.get("theme")
 | 
					    theme = request.form.get("theme")
 | 
				
			||||||
 | 
					    username = request.form.get("username")
 | 
				
			||||||
 | 
					    password = request.form.get("password")
 | 
				
			||||||
 | 
					    changed_credentials = False
 | 
				
			||||||
    if entryquota.isnumeric() and int(entryquota) > 0:  # type: ignore
 | 
					    if entryquota.isnumeric() and int(entryquota) > 0:  # type: ignore
 | 
				
			||||||
        app.config['ENTRY_QUOTA'] = int(entryquota)  # type: ignore
 | 
					        app.config['ENTRY_QUOTA'] = int(entryquota)  # type: ignore
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
@@ -91,14 +94,21 @@ def settings_post():
 | 
				
			|||||||
        app.config['MAX_QUEUE'] = int(maxqueue)  # type: ignore
 | 
					        app.config['MAX_QUEUE'] = int(maxqueue)  # type: ignore
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        abort(400)
 | 
					        abort(400)
 | 
				
			||||||
    if theme in helpers.get_themes():
 | 
					    if theme is not None and theme in helpers.get_themes():
 | 
				
			||||||
        app.config['THEME'] = theme
 | 
					        helpers.set_theme(app,theme)
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        abort(400)
 | 
					        abort(400)
 | 
				
			||||||
 | 
					    if username != "" and username != app.config['BASIC_AUTH_USERNAME']:
 | 
				
			||||||
 | 
					        app.config['BASIC_AUTH_USERNAME'] = username
 | 
				
			||||||
 | 
					        changed_credentials = True
 | 
				
			||||||
 | 
					    if password != "":
 | 
				
			||||||
 | 
					        app.config['BASIC_AUTH_PASSWORD'] = password
 | 
				
			||||||
 | 
					        changed_credentials = True
 | 
				
			||||||
    helpers.persist_config(app=app)
 | 
					    helpers.persist_config(app=app)
 | 
				
			||||||
 | 
					    if changed_credentials:
 | 
				
			||||||
    return render_template('settings.html', app=app, auth=basic_auth.authenticate())
 | 
					        return redirect("/")
 | 
				
			||||||
 | 
					    else:
 | 
				
			||||||
 | 
					        return render_template('settings.html', app=app, auth=basic_auth.authenticate(), themes=helpers.get_themes())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@app.route("/api/queue")
 | 
					@app.route("/api/queue")
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,6 +18,18 @@
 | 
				
			|||||||
            {% endfor %}
 | 
					            {% endfor %}
 | 
				
			||||||
        </select>
 | 
					        </select>
 | 
				
			||||||
    </p>
 | 
					    </p>
 | 
				
			||||||
 | 
					    <div class="alert alert-warning" role="alert">
 | 
				
			||||||
 | 
					        <i class="fas fa-exclamation-triangle mr-1"></i>
 | 
				
			||||||
 | 
					        <strong>Warnung:</strong> Änderungen an den folgenden Einstellungen führen zu einer sofortigen Abmeldung!
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					    <p>
 | 
				
			||||||
 | 
					        <label for="username">Benutzername</label>
 | 
				
			||||||
 | 
					        <input type="text" class="form-control" id="username" name="username" value={{app.config['BASIC_AUTH_USERNAME']}}>
 | 
				
			||||||
 | 
					    </p>
 | 
				
			||||||
 | 
					    <p>
 | 
				
			||||||
 | 
					        <label for="password">Passwort ändern</label>
 | 
				
			||||||
 | 
					        <input type="password" class="form-control" id="password" name="password">
 | 
				
			||||||
 | 
					    </p>
 | 
				
			||||||
    <input type="submit" class="btn btn-primary mr-1 mb-2" value="Einstellungen anwenden">
 | 
					    <input type="submit" class="btn btn-primary mr-1 mb-2" value="Einstellungen anwenden">
 | 
				
			||||||
</form>
 | 
					</form>
 | 
				
			||||||
<details>
 | 
					<details>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user