Django-Allauth remove email field in signup form - django

I only use Linked-In as means to authenticate. When the user gives permission in Linked-In, he get's send to my own form so I can gather extra information. But it seems Allauth only lets me add fields to the default form using:
ACCOUNT_SIGNUP_FORM_CLASS = 'myapp.forms.MySignUpForm'
But the email field is always visible (and filled in with the email from Linked-In). Is it true that I have no way of dropping this field? I don't want the user to be able to change his email into something else than his Linked-In email.

Related

Change django-allauth email verification behaivior

Django has builtin User model is_active field. I assume that django-allauth sets this field to True after successful e-mail verification.
I would manually enable the user and change this field to "true" via the Django admin interface instead.
Is it possible to change this behavior from django-allauth?
is_active is, like you mentioned, used to determine whether its an active account, and can be flipped to False instead of deleting the acccount. But I don't think all-auth does anything with this value, it is automatically set to True when you create a User object.
What you are looking for is in a separate table, usually "email_addresses". This will show which email addresses have been verified.

Django User model with encrypted and hashed email as username

I have a custom User model with email as username.
I have encrypted the email field to be in conformity with GPDR (I will hold a lot of personal information).
I have added a email_hash field with index on it for the database to be able to retrieve immediately user.
I have modified get_natural_key of my user object manager to use the hash for retrieve.
But now i face a problem I have to disable the uniqueness on field email (username field) but Django don't let me do it when i try to makemigrations.
myuser.MyUser: (auth.E003) 'MyUser.email' must be unique because it is named as the 'USERNAME_FIELD'.
Otherwise, I want the uniqueness error to be fired on email field and not on email_hash field ....
How to have functional encrypted email field as user and stored hash for index ?
edit:
I have disable uniqueness check on email field and added SILENCED_SYSTEM_CHECKS = ["auth.E003"] in settings.
Now my problem is to have uniqueness error of email_hash rendered as email error to have "A user with that email address already exists." message displayed on correct forms and django rest framework serializer field.

Increasing User model's field length without overriding

Using django 1.9
In our project we decided to use e-mail field instead of username field of User.
We tried to do it without overriding django.contrib.auth's User model, so just hid the username field in registration form to fill it with e-mail field's data. The problem is the username field has max_len=30, e-mail field - max_len=254.
Which is the best approach to solve it without overriding User model, if possible?

django: send an email with username and password information

I want to create username and password when I press on submit button of registration form. Where full name of user is entered by the user. And then username and password should be sent to the user.
Can anyone suggest how to do?
You can find the documentation on creating a user at https://docs.djangoproject.com/en/1.5/topics/auth/default/#creating-users and the documentation on sending an email at https://docs.djangoproject.com/en/1.5/topics/email/ .
It's basically just a matter of creating a form, writing a view to render it, and if the form is valid, create the user using that data and send the email off.

Sound strategy for extending Django User model?

This seems like it should be fine, since I'm not touching the User model itself.
I want to register users purely based on email and password. Username is required in the User model. My thought is that I can just create a custom UserCreationForm that saves email address AS username and validates the email address.
Unfortunately, with that, I'll have to refer to email address via user.username going forward.
Is this standard? Is there a better way?
Thanks
Some answers here.
Seems like the best method may be to write a custom auth backend (not too difficult) to accept email addresses to log in, and store a hash of the email in the username field to satisfy the required, unique username.
My thought is that I can just create a custom UserCreationForm that saves email address AS username and validates the email address.
Close.
Use the clean method to copy email address to username. This works out pretty well for everything but the default login form.
The default login form needs to be tweaked to allow username to be an email address. The default form expects characters only, and rejects punctuation.