-
-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Starting to add emails * Send email helper now works fine * Starting to make magic links (will finish tomorrow) * Cleaned up auth, added namespace. Also started working on magic links * Started to add hashed token verification for emails * Improved authentication with is_active messages * Started adding the ability to resend a verification code * Added new user fields to djangp admin * Improved resend email feature * Added discord to docs * Started adding a slider type design to login. A step progress. (not finished) * Started adding Login magic links. Nearly done, need to add the ability to accept login requests * Added the ability to accept magic link requests, also redirects to "?next" url if there is one * Ran djlint formatter * Ran black formatter * Added missing migration file * Added new type hint values * Moved boto3 stubs to main dependencies so installed for tests * Removed failing tests * Fixed manual login
- Loading branch information
Showing
62 changed files
with
2,194 additions
and
559 deletions.
There are no files selected for viewing
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,15 +1,27 @@ | ||
from django.contrib.auth.backends import ModelBackend | ||
from django.contrib.auth import get_user_model | ||
from django.contrib.auth.backends import ModelBackend | ||
|
||
|
||
class EmailInsteadOfUsernameBackend(ModelBackend): | ||
def authenticate(self, request, username=None, password=None, **kwargs): | ||
UserModel = get_user_model() | ||
|
||
if username is None or password is None: | ||
return | ||
|
||
try: | ||
user = UserModel.objects.get(email=username) | ||
except UserModel.DoesNotExist: | ||
# Run the default password hasher once to reduce the timing | ||
# difference between an existing and a nonexistent user (#20760). | ||
UserModel().set_password(password) | ||
return None | ||
else: | ||
if user.check_password(password): | ||
if user.is_active: | ||
return user | ||
|
||
if user.awaiting_email_verification: | ||
return user | ||
return user | ||
return None | ||
return None |
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
74 changes: 74 additions & 0 deletions
74
backend/migrations/0019_alter_featureflags_options_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,74 @@ | ||
# Generated by Django 5.0.2 on 2024-02-22 18:16 | ||
|
||
import datetime | ||
import uuid | ||
|
||
import django.db.models.deletion | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("backend", "0018_user_role"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterModelOptions( | ||
name="featureflags", | ||
options={ | ||
"verbose_name": "Feature Flag", | ||
"verbose_name_plural": "Feature Flags", | ||
}, | ||
), | ||
migrations.AddField( | ||
model_name="user", | ||
name="awaiting_email_verification", | ||
field=models.BooleanField(default=True), | ||
), | ||
migrations.CreateModel( | ||
name="VerificationCodes", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
( | ||
"uuid", | ||
models.UUIDField(default=uuid.uuid4, editable=False, unique=True), | ||
), | ||
("created", models.DateTimeField(auto_now_add=True)), | ||
( | ||
"expiry", | ||
models.DateTimeField( | ||
default=datetime.datetime( | ||
2024, 2, 22, 21, 16, 55, 46745, tzinfo=datetime.timezone.utc | ||
) | ||
), | ||
), | ||
( | ||
"service", | ||
models.CharField( | ||
choices=[ | ||
("create_account", "Create Account"), | ||
("reset_password", "Reset Password"), | ||
], | ||
max_length=14, | ||
), | ||
), | ||
( | ||
"user", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
], | ||
), | ||
] |
36 changes: 36 additions & 0 deletions
36
backend/migrations/0020_alter_verificationcodes_options_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,36 @@ | ||
# Generated by Django 5.0.2 on 2024-02-22 20:41 | ||
|
||
import datetime | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("backend", "0019_alter_featureflags_options_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterModelOptions( | ||
name="verificationcodes", | ||
options={ | ||
"verbose_name": "Verification Code", | ||
"verbose_name_plural": "Verification Codes", | ||
}, | ||
), | ||
migrations.AddField( | ||
model_name="verificationcodes", | ||
name="token", | ||
field=models.TextField(default="BZQQWE", editable=False), | ||
), | ||
migrations.AlterField( | ||
model_name="verificationcodes", | ||
name="expiry", | ||
field=models.DateTimeField( | ||
default=datetime.datetime( | ||
2024, 2, 22, 23, 41, 26, 332896, tzinfo=datetime.timezone.utc | ||
) | ||
), | ||
), | ||
] |
29 changes: 29 additions & 0 deletions
29
backend/migrations/0021_alter_verificationcodes_expiry_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,29 @@ | ||
# Generated by Django 5.0.2 on 2024-02-23 19:00 | ||
|
||
import datetime | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("backend", "0020_alter_verificationcodes_options_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="verificationcodes", | ||
name="expiry", | ||
field=models.DateTimeField( | ||
default=datetime.datetime( | ||
2024, 2, 23, 22, 0, 25, 744643, tzinfo=datetime.timezone.utc | ||
) | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="verificationcodes", | ||
name="token", | ||
field=models.TextField(default="XBNKTM", editable=False), | ||
), | ||
] |
30 changes: 30 additions & 0 deletions
30
backend/migrations/0022_loginlog_service_alter_verificationcodes_expiry_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,30 @@ | ||
# Generated by Django 5.0.2 on 2024-02-25 11:42 | ||
|
||
from django.db import migrations, models | ||
|
||
import backend.models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("backend", "0021_alter_verificationcodes_expiry_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="loginlog", | ||
name="service", | ||
field=models.CharField(choices=[("manual", "Manual"), ("magic_link", "Magic Link")], default="manual", max_length=14), | ||
), | ||
migrations.AlterField( | ||
model_name="verificationcodes", | ||
name="expiry", | ||
field=models.DateTimeField(default=backend.models.add_3hrs_from_now), | ||
), | ||
migrations.AlterField( | ||
model_name="verificationcodes", | ||
name="token", | ||
field=models.TextField(default=backend.models.RandomCode, editable=False), | ||
), | ||
] |
Oops, something went wrong.