API/UI - Button to regenerate API key (#1975 / #1967)

pull/1748/merge
dgtlmoon 1 year ago committed by GitHub
parent c8dcc072c8
commit 5a306aa78c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -819,6 +819,16 @@ def changedetection_app(config=None, datastore_o=None):
return output return output
@app.route("/settings/reset-api-key", methods=['GET'])
@login_optionally_required
def settings_reset_api_key():
import secrets
secret = secrets.token_hex(16)
datastore.data['settings']['application']['api_access_token'] = secret
datastore.needs_write_urgent = True
flash("API Key was regenerated.")
return redirect(url_for('settings_page')+'#api')
@app.route("/import", methods=['GET', "POST"]) @app.route("/import", methods=['GET', "POST"])
@login_optionally_required @login_optionally_required
def import_page(): def import_page():

@ -178,6 +178,9 @@ nav
<span style="display:none;" id="api-key-copy" >copy</span> <span style="display:none;" id="api-key-copy" >copy</span>
</div> </div>
</div> </div>
<div class="pure-control-group">
<a href="{{url_for('settings_reset_api_key')}}" class="pure-button button-small button-cancel">Regenerate API key</a>
</div>
</div> </div>
<div class="tab-pane-inner" id="proxies"> <div class="tab-pane-inner" id="proxies">
<div id="recommended-proxy"> <div id="recommended-proxy">

Loading…
Cancel
Save