added BUG-120, somehow losing pref info. No prints are working in PROD, so changed a lot of printf( in the F/E to SetFELog with error and persistent/cant_close set across many files. Also used opportunity to remove a few unnecessary debugs

This commit is contained in:
2023-04-09 13:10:28 +10:00
parent cdef403187
commit a84ff49413
6 changed files with 40 additions and 23 deletions

View File

@@ -23,7 +23,6 @@ from flask_ldap3_login.forms import LDAPLoginForm
####################################### Flask App globals #######################################
hostname = socket.gethostname()
print( "Running on: {}".format( hostname) )
app = Flask(__name__)
@@ -38,8 +37,6 @@ try:
except Exception:
app.config['SECRET_KEY'] = b'my_insecure_PA_token_with_random_2134876adsfjhlkasdf87'
print(app.config['SECRET_KEY'])
# ldap config vars: (the last one is required, or python ldap freaks out)
app.config['LDAP_HOST'] = 'mara.ddp.net'
app.config['LDAP_BASE_DN'] = 'dc=depaoli,dc=id,dc=au'
@@ -67,6 +64,7 @@ from files import Entry
from person import Person
from settings import Settings
from user import PAUser
from job import SetFELog
####################################### GLOBALS #######################################
# allow jinja2 to call these python functions directly
@@ -122,7 +120,7 @@ def login():
# the re matches on any special LDAP chars, we dont want someone
# ldap-injecting our username, so send them back to the login page instead
if request.method == 'POST' and re.search( r'[()\\*&!]', request.form['username']):
print( f"WARNING: Detected special LDAP chars in username: {request.form['username']}")
SetFELog( message=f"ERROR: Detected special LDAP chars in username: {request.form['username']}", log_level="error", persistent=True, cant_close=True )
return redirect(url_for('login'))
if form.validate_on_submit():
# Successfully logged in, We can now access the saved user object via form.user.