I register a user without a password, an error comes that such a user does not exist. But at the same time yuh
eshpilevsky opened this issue · comments
{
"data": {
"createUser": {
"success": false,
"errors": {
"email": [
{
"message": "Custom user with this Email already exists.",
"code": "unique"
}
]
}
}
}
}
class Mutation(graphene.ObjectType):
create_user = mutations.Register.Field()
ALLOW_PASSWORDLESS_REGISTRATION = True
GRAPHQL_AUTH = {
"LOGIN_ALLOWED_FIELDS": ['email'],
"REGISTER_MUTATION_FIELDS": ['first_name', 'last_name', 'email', 'role'],
"ALLOW_LOGIN_NOT_VERIFIED": False,
"ALLOW_PASSWORDLESS_REGISTRATION": True,
"SEND_PASSWORD_SET_EMAIL": True,
"SEND_ACTIVATION_EMAIL": False,
}
class CustomUser(AbstractUser):
class Meta:
db_table = "user"
ROLES = (
('Student', 'Student'),
('Teacher', 'Teacher'),
('Accountant', 'Accountant'),
('Manager', 'Manager'),
)
first_name = models.CharField(max_length=100)
last_name = models.CharField(max_length=100)
email = models.EmailField("Email", unique=True)
role = models.CharField(max_length=50, choices=ROLES)
is_student = models.BooleanField(default=False)
is_teacher = models.BooleanField(default=False)
is_accountant = models.BooleanField(default=False)
is_manager = models.BooleanField(default=False)
USERNAME_FIELD = "email"
REQUIRED_FIELDS = ["username"]
def __str__(self):
return self.email
def save(self, *args, **kwargs):
if self.role == 'Student':
self.is_student = True
elif self.role == 'Teacher':
self.is_teacher = True
elif self.role == 'Accountant':
self.is_accountant = True
elif self.role == 'Manager':
self.is_manager = True
super(CustomUser, self).save(*args, **kwargs)
Hi @eshpilevsky thanks for your issue, please use the issue template.
Moreover in case that your second comment modifies the initial one feel free to delete the first one.