added route for token backup
This commit is contained in:
parent
f021f7494f
commit
312549ac15
|
@ -529,6 +529,19 @@ def create_application(config):
|
|||
flash(f"Error during store_tokens. Exception: {e}")
|
||||
return redirect('/tokens')
|
||||
|
||||
@app.route('/backup_tokens')
|
||||
@auth_required()
|
||||
def backup_tokens():
|
||||
# get list of defined admin users for backup
|
||||
tokens = door.get_tokens()
|
||||
try:
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
file = Path(tmpdir, 'token_data.txt')
|
||||
file.write_text(json.dumps(tokens))
|
||||
return send_file(file, as_attachment=True, cache_timeout=-1)
|
||||
except Exception as e:
|
||||
return str(e)
|
||||
|
||||
@app.route('/open')
|
||||
@auth_required()
|
||||
def open_door():
|
||||
|
|
Loading…
Reference in New Issue
Block a user