Skip to content

Commit e631688

Browse files
committed
Remove auth.User model
1 parent d3399ef commit e631688

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

bolt-auth/bolt/auth/forms.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from bolt import forms
44
from bolt.auth import authenticate, get_user_model, password_validation
5-
from bolt.auth.models import User
65
from bolt.auth.tokens import default_token_generator
76
from bolt.db.forms import ModelForm
87
from bolt.exceptions import ValidationError
@@ -98,7 +97,7 @@ class BaseUserCreationForm(ModelForm):
9897
)
9998

10099
class Meta:
101-
model = User
100+
model = get_user_model()
102101
fields = ("username",)
103102
field_classes = {"username": UsernameField}
104103

@@ -149,7 +148,10 @@ class UserCreationForm(BaseUserCreationForm):
149148
def clean_username(self):
150149
"""Reject usernames that differ only in case."""
151150
username = self.cleaned_data.get("username")
152-
if username and User.objects.filter(username__iexact=username).exists():
151+
if (
152+
username
153+
and get_user_model().objects.filter(username__iexact=username).exists()
154+
):
153155
raise forms.ValidationError(self.error_messages["unique"], code="unique")
154156
else:
155157
return username
@@ -166,7 +168,7 @@ class UserChangeForm(ModelForm):
166168
)
167169

168170
class Meta:
169-
model = User
171+
model = get_user_model()
170172
fields = "__all__"
171173
field_classes = {"username": UsernameField}
172174

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Generated by Bolt 5.0.dev20240205033503 on 2024-02-05 03:42
2+
3+
from bolt.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
dependencies = [
8+
("auth", "0002_remove_user_is_superuser"),
9+
]
10+
11+
operations = [
12+
migrations.DeleteModel(
13+
name="User",
14+
),
15+
]

bolt-auth/bolt/auth/models.py

-12
Original file line numberDiff line numberDiff line change
@@ -205,15 +205,3 @@ def normalize_username(cls, username):
205205
if isinstance(username, str)
206206
else username
207207
)
208-
209-
210-
class User(AbstractUser):
211-
"""
212-
Users within the Bolt authentication system are represented by this
213-
model.
214-
215-
Username and password are required. Other fields are optional.
216-
"""
217-
218-
class Meta(AbstractUser.Meta):
219-
swappable = "AUTH_USER_MODEL"

0 commit comments

Comments
 (0)