Browse Source

Fix username blacklist

sh4nks 8 years ago
parent
commit
d667209fe0
3 changed files with 7 additions and 4 deletions
  1. 4 1
      flaskbb/auth/forms.py
  2. 2 2
      flaskbb/cli/main.py
  3. 1 1
      flaskbb/utils/populate.py

+ 4 - 1
flaskbb/auth/forms.py

@@ -71,12 +71,15 @@ class RegisterForm(FlaskForm):
         # would through an out of context error if used with validators.Length
         # would through an out of context error if used with validators.Length
         min_length = flaskbb_config["AUTH_USERNAME_MIN_LENGTH"]
         min_length = flaskbb_config["AUTH_USERNAME_MIN_LENGTH"]
         max_length = flaskbb_config["AUTH_USERNAME_MAX_LENGTH"]
         max_length = flaskbb_config["AUTH_USERNAME_MAX_LENGTH"]
+        blacklist = [w.strip() for w in
+                     flaskbb_config["AUTH_USERNAME_BLACKLIST"].split(",")]
+
         if len(field.data) < min_length or len(field.data) > max_length:
         if len(field.data) < min_length or len(field.data) > max_length:
             raise ValidationError(_(
             raise ValidationError(_(
                 "Username must be between %(min)s and %(max)s characters long.",
                 "Username must be between %(min)s and %(max)s characters long.",
                 min=min_length, max=max_length)
                 min=min_length, max=max_length)
             )
             )
-        if field.data.lower() in flaskbb_config["AUTH_USERNAME_BLACKLIST"]:
+        if field.data.lower() in blacklist:
             raise ValidationError(_(
             raise ValidationError(_(
                 "This is a system reserved name. Choose a different one.")
                 "This is a system reserved name. Choose a different one.")
             )
             )

+ 2 - 2
flaskbb/cli/main.py

@@ -201,12 +201,12 @@ def upgrade(all_latest, fixture, force):
             raise FlaskBBCLIError("{} fixture is not available"
             raise FlaskBBCLIError("{} fixture is not available"
                                   .format(fixture), fg="red")
                                   .format(fixture), fg="red")
 
 
-        click.secho("[+] Updating fixtures...")
+        click.secho("[+] Updating fixtures...", fg="cyan")
         count = update_settings_from_fixture(
         count = update_settings_from_fixture(
             fixture=settings, overwrite_group=force, overwrite_setting=force
             fixture=settings, overwrite_group=force, overwrite_setting=force
         )
         )
         click.secho("[+] {} groups and {} settings updated.".format(
         click.secho("[+] {} groups and {} settings updated.".format(
-            len(count.keys()), len(count.values()), fg="green")
+            len(count.keys()), len(count.values())), fg="green"
         )
         )
 
 
 
 

+ 1 - 1
flaskbb/utils/populate.py

@@ -104,7 +104,6 @@ def update_settings_from_fixture(fixture, overwrite_group=False,
                 )
                 )
 
 
             group.save()
             group.save()
-        updated_settings[group] = []
 
 
         for settings in settingsgroup[1]["settings"]:
         for settings in settingsgroup[1]["settings"]:
 
 
@@ -131,6 +130,7 @@ def update_settings_from_fixture(fixture, overwrite_group=False,
                     )
                     )
 
 
                 setting.save()
                 setting.save()
+                updated_settings[group] = []
                 updated_settings[group].append(setting)
                 updated_settings[group].append(setting)
     return updated_settings
     return updated_settings