kopia lustrzana https://github.com/dgtlmoon/changedetection.io
Ability to reset app password by placing a file called removepassword.lock into your data directory and restarting the instance
rodzic
ed7c2f01da
commit
03c1ad3989
|
@ -189,6 +189,10 @@ def changedetection_app(config=None, datastore_o=None):
|
||||||
@app.route('/login', methods=['GET', 'POST'])
|
@app.route('/login', methods=['GET', 'POST'])
|
||||||
def login():
|
def login():
|
||||||
|
|
||||||
|
if not datastore.data['settings']['application']['password']:
|
||||||
|
flash("Login not required, no password enabled.", "notice")
|
||||||
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
output = render_template("login.html")
|
output = render_template("login.html")
|
||||||
return output
|
return output
|
||||||
|
@ -483,9 +487,6 @@ def changedetection_app(config=None, datastore_o=None):
|
||||||
flash("Password protection enabled.", 'notice')
|
flash("Password protection enabled.", 'notice')
|
||||||
flask_login.logout_user()
|
flask_login.logout_user()
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
else:
|
|
||||||
# Unset it anyway, just to be sure.
|
|
||||||
datastore.data['settings']['application']['password'] = False
|
|
||||||
|
|
||||||
flash("Settings updated.")
|
flash("Settings updated.")
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
|
from os import unlink, path, mkdir
|
||||||
import json
|
import json
|
||||||
import uuid as uuid_builder
|
import uuid as uuid_builder
|
||||||
import os.path
|
|
||||||
from os import path
|
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
|
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
@ -115,6 +113,12 @@ class ChangeDetectionStore:
|
||||||
|
|
||||||
self.__data['version_tag'] = "0.34"
|
self.__data['version_tag'] = "0.34"
|
||||||
|
|
||||||
|
# Helper to remove password protection
|
||||||
|
password_reset_lockfile = "{}/removepassword.lock".format(self.datastore_path)
|
||||||
|
if path.isfile(password_reset_lockfile):
|
||||||
|
self.__data['settings']['application']['password'] = False
|
||||||
|
unlink(password_reset_lockfile)
|
||||||
|
|
||||||
if not 'app_guid' in self.__data:
|
if not 'app_guid' in self.__data:
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
@ -199,7 +203,7 @@ class ChangeDetectionStore:
|
||||||
|
|
||||||
def unlink_history_file(self, path):
|
def unlink_history_file(self, path):
|
||||||
try:
|
try:
|
||||||
os.unlink(path)
|
unlink(path)
|
||||||
except (FileNotFoundError, IOError):
|
except (FileNotFoundError, IOError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -293,7 +297,7 @@ class ChangeDetectionStore:
|
||||||
# Get the directory ready
|
# Get the directory ready
|
||||||
output_path = "{}/{}".format(self.datastore_path, new_uuid)
|
output_path = "{}/{}".format(self.datastore_path, new_uuid)
|
||||||
try:
|
try:
|
||||||
os.mkdir(output_path)
|
mkdir(output_path)
|
||||||
except FileExistsError:
|
except FileExistsError:
|
||||||
print(output_path, "already exists.")
|
print(output_path, "already exists.")
|
||||||
|
|
||||||
|
@ -362,4 +366,4 @@ class ChangeDetectionStore:
|
||||||
for item in pathlib.Path(self.datastore_path).rglob("*/*txt"):
|
for item in pathlib.Path(self.datastore_path).rglob("*/*txt"):
|
||||||
if not str(item) in index:
|
if not str(item) in index:
|
||||||
print ("Removing",item)
|
print ("Removing",item)
|
||||||
os.unlink(item)
|
unlink(item)
|
||||||
|
|
Ładowanie…
Reference in New Issue