-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update to Django 4.0 `django-clacks` was removed temporarily until we figure out why poetry won't lock the dependencies with clacks included. * Drop CI text fields in favour of charfields A unique constraint is created on the database in order to prevent duplicate signups using a name that only differs in casing for both users as well as teams. Two test cases are added to verify this behaviour. * Re-add django-clacks * Truncate data in migration Co-authored-by: Daniel Milnes <thebeanogamer@gmail.com> * Reject usernames with a length > 36 Co-authored-by: Daniel Milnes <thebeanogamer@gmail.com> Co-authored-by: David Cooke <me@dave.lc>
- Loading branch information
1 parent
3dd84ca
commit 2d492a6
Showing
12 changed files
with
797 additions
and
581 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
from django.dispatch import Signal | ||
|
||
flag_score = Signal(providing_args=["user", "team", "challenge", "flag", "solve"]) | ||
flag_reject = Signal(providing_args=["user", "team", "challenge", "flag", "reason"]) | ||
flag_submit = Signal(providing_args=["user", "team", "challenge", "flag"]) | ||
team_join = Signal(providing_args=["user", "team"]) | ||
team_join_attempt = Signal(providing_args=["user", "team_name"]) | ||
team_join_reject = Signal(providing_args=["user", "team_name"]) | ||
team_create = Signal(providing_args=["team"]) | ||
use_hint = Signal(providing_args=["user", "team", "hint"]) | ||
logout = Signal(providing_args=["user"]) | ||
add_2fa = Signal(providing_args=["user"]) | ||
verify_2fa = Signal(providing_args=["user"]) | ||
remove_2fa = Signal(providing_args=["user"]) | ||
password_reset = Signal(providing_args=["user"]) | ||
password_reset_start = Signal(providing_args=["user"]) | ||
password_reset_start_reject = Signal(providing_args=["email"]) | ||
email_verified = Signal(providing_args=["user"]) | ||
change_password = Signal(providing_args=["user"]) | ||
login = Signal(providing_args=["user"]) | ||
login_reject = Signal(providing_args=["username", "reason"]) | ||
register = Signal(providing_args=["user"]) | ||
register_reject = Signal(providing_args=["username", "email"]) | ||
websocket_connect = Signal(providing_args=["channel_layer"]) | ||
websocket_disconnect = Signal(providing_args=["channel_layer"]) | ||
flag_score = Signal() | ||
flag_reject = Signal() | ||
flag_submit = Signal() | ||
team_join = Signal() | ||
team_join_attempt = Signal() | ||
team_join_reject = Signal() | ||
team_create = Signal() | ||
use_hint = Signal() | ||
logout = Signal() | ||
add_2fa = Signal() | ||
verify_2fa = Signal() | ||
remove_2fa = Signal() | ||
password_reset = Signal() | ||
password_reset_start = Signal() | ||
password_reset_start_reject = Signal() | ||
email_verified = Signal() | ||
change_password = Signal() | ||
login = Signal() | ||
login_reject = Signal() | ||
register = Signal() | ||
register_reject = Signal() | ||
websocket_connect = Signal() | ||
websocket_disconnect = Signal() |
43 changes: 43 additions & 0 deletions
43
src/member/migrations/0009_alter_member_options_alter_member_username_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Generated by Django 4.0.2 on 2022-02-11 21:43 | ||
|
||
import backend.validators | ||
from django.db import migrations, models | ||
import django.db.models.functions.text | ||
|
||
|
||
def truncate_usernames(apps, schema_editor): | ||
Member = apps.get_model('member', 'member') | ||
db_alias = schema_editor.connection.alias | ||
for member in Member.objects.using(db_alias).all(): | ||
if len(member.username) > 36: | ||
member.username = member.username[:36] | ||
member.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('member', '0008_remove_member_password_reset_token'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterModelOptions( | ||
name='member', | ||
options={}, | ||
), | ||
migrations.RunPython( | ||
truncate_usernames, | ||
# Marked as elidable since when we squash we will have the 36 characters | ||
# in by default | ||
elidable=True, | ||
), | ||
migrations.AlterField( | ||
model_name='member', | ||
name='username', | ||
field=models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 36 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=36, unique=True, validators=[backend.validators.printable_name], verbose_name='username'), | ||
), | ||
migrations.AddConstraint( | ||
model_name='member', | ||
constraint=models.UniqueConstraint(django.db.models.functions.text.Lower('username'), name='member_member_username_uniq_idx'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/team/migrations/0004_alter_team_name_team_team_team_username_uniq_idx.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Generated by Django 4.0.2 on 2022-02-11 21:43 | ||
|
||
import backend.validators | ||
from django.db import migrations, models | ||
import django.db.models.functions.text | ||
|
||
|
||
def truncate_usernames(apps, schema_editor): | ||
Team = apps.get_model('team', 'team') | ||
db_alias = schema_editor.connection.alias | ||
for team in Team.objects.using(db_alias).all(): | ||
if len(team.name) > 36: | ||
team.name = team.name[:36] | ||
team.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('team', '0003_team_size_limit_exempt'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython( | ||
truncate_usernames, | ||
# Marked as elidable since when we squash we will have the 36 characters | ||
# in by default | ||
elidable=True, | ||
), | ||
migrations.AlterField( | ||
model_name='team', | ||
name='name', | ||
field=models.CharField(max_length=36, unique=True, validators=[backend.validators.printable_name]), | ||
), | ||
migrations.AddConstraint( | ||
model_name='team', | ||
constraint=models.UniqueConstraint(django.db.models.functions.text.Lower('name'), name='team_team_username_uniq_idx'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters