Prevent logging in as the superuser

This commit is contained in:
Tanner Collin 2023-07-12 18:24:49 +00:00
parent 8ca2dc420a
commit 8baf204516

View File

@ -1066,6 +1066,11 @@ class MyLoginSerializer(LoginSerializer):
if not User.objects.filter(username=username).exists():
raise ValidationError(dict(username='Username not found. Try "first.last" or "first.middle.last".'))
try:
_ = User.objects.get(username=username).member
except User.member.RelatedObjectDoesNotExist:
raise ValidationError(dict(username='Can\'t log in as superuser. Make an account below.'))
user = super().authenticate(**kwargs)
if not user: