Rename config user.min_length -> min_username_length.
This commit is contained in:
parent
21bd211889
commit
4434517c54
4 changed files with 16 additions and 8 deletions
|
@ -42,7 +42,7 @@ FILENAME_BADCHARS = '\\/:*?<>|"'
|
||||||
# Note: Setting user_version pragma in init sequence is safe because it only
|
# Note: Setting user_version pragma in init sequence is safe because it only
|
||||||
# happens after the out-of-date check occurs, so no chance of accidentally
|
# happens after the out-of-date check occurs, so no chance of accidentally
|
||||||
# overwriting it.
|
# overwriting it.
|
||||||
DATABASE_VERSION = 13
|
DATABASE_VERSION = 14
|
||||||
DB_INIT = f'''
|
DB_INIT = f'''
|
||||||
PRAGMA cache_size = 10000;
|
PRAGMA cache_size = 10000;
|
||||||
PRAGMA count_changes = OFF;
|
PRAGMA count_changes = OFF;
|
||||||
|
@ -305,10 +305,10 @@ DEFAULT_CONFIGURATION = {
|
||||||
},
|
},
|
||||||
|
|
||||||
'user': {
|
'user': {
|
||||||
'min_length': 2,
|
'min_username_length': 2,
|
||||||
'min_password_length': 6,
|
'min_password_length': 6,
|
||||||
'max_display_name_length': 24,
|
'max_display_name_length': 24,
|
||||||
'max_length': 24,
|
'max_username_length': 24,
|
||||||
'valid_chars': string.ascii_letters + string.digits + '_-',
|
'valid_chars': string.ascii_letters + string.digits + '_-',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -933,16 +933,16 @@ class PDBUserMixin:
|
||||||
raise exceptions.PasswordTooShort(min_length=self.config['user']['min_password_length'])
|
raise exceptions.PasswordTooShort(min_length=self.config['user']['min_password_length'])
|
||||||
|
|
||||||
def _assert_valid_username(self, username):
|
def _assert_valid_username(self, username):
|
||||||
if len(username) < self.config['user']['min_length']:
|
if len(username) < self.config['user']['min_username_length']:
|
||||||
raise exceptions.UsernameTooShort(
|
raise exceptions.UsernameTooShort(
|
||||||
username=username,
|
username=username,
|
||||||
min_length=self.config['user']['min_length']
|
min_length=self.config['user']['min_username_length']
|
||||||
)
|
)
|
||||||
|
|
||||||
if len(username) > self.config['user']['max_length']:
|
if len(username) > self.config['user']['max_username_length']:
|
||||||
raise exceptions.UsernameTooLong(
|
raise exceptions.UsernameTooLong(
|
||||||
username=username,
|
username=username,
|
||||||
max_length=self.config['user']['max_length']
|
max_length=self.config['user']['max_username_length']
|
||||||
)
|
)
|
||||||
|
|
||||||
badchars = [c for c in username if c not in self.config['user']['valid_chars']]
|
badchars = [c for c in username if c not in self.config['user']['valid_chars']]
|
||||||
|
|
|
@ -48,7 +48,7 @@ def get_login():
|
||||||
response = flask.render_template(
|
response = flask.render_template(
|
||||||
'login.html',
|
'login.html',
|
||||||
session=session,
|
session=session,
|
||||||
min_username_length=common.P.config['user']['min_length'],
|
min_username_length=common.P.config['user']['min_username_length'],
|
||||||
min_password_length=common.P.config['user']['min_password_length'],
|
min_password_length=common.P.config['user']['min_password_length'],
|
||||||
)
|
)
|
||||||
return response
|
return response
|
||||||
|
|
|
@ -257,6 +257,14 @@ def upgrade_12_to_13(photodb):
|
||||||
cur.execute('DROP TABLE users_old')
|
cur.execute('DROP TABLE users_old')
|
||||||
cur.execute('PRAGMA foreign_keys = ON')
|
cur.execute('PRAGMA foreign_keys = ON')
|
||||||
|
|
||||||
|
def upgrade_13_to_14(photodb):
|
||||||
|
'''
|
||||||
|
Rename user.min_length to min_username_length.
|
||||||
|
'''
|
||||||
|
photodb.config['user']['min_username_length'] = photodb.config['user'].pop('min_length')
|
||||||
|
photodb.config['user']['max_username_length'] = photodb.config['user'].pop('max_length')
|
||||||
|
photodb.save_config()
|
||||||
|
|
||||||
def upgrade_all(data_directory):
|
def upgrade_all(data_directory):
|
||||||
'''
|
'''
|
||||||
Given the directory containing a phototagger database, apply all of the
|
Given the directory containing a phototagger database, apply all of the
|
||||||
|
|
Loading…
Reference in a new issue