Skip to content
This repository has been archived by the owner on Jun 6, 2018. It is now read-only.

Could there be an option to disable asking for an email entirely? #1060

Open
GoldenCoins opened this issue May 13, 2018 · 2 comments
Open

Could there be an option to disable asking for an email entirely? #1060

GoldenCoins opened this issue May 13, 2018 · 2 comments

Comments

@GoldenCoins
Copy link

At the moment there is the option in the settings file to not verify emails upon registration, is there a way to stop it asking for one completely?

@Adarnof
Copy link
Member

Adarnof commented May 13, 2018

I'd really rather not. Service integrations were written under the assumption that all users have an entered email address. Some services require this to be valid. I'm not keen on going through and introducing error handling to services that require an email.

You could bypass that form in your auth project by overriding the view. You would need a custom view like:

def complete_registraion(request):
    user = User.objects.get(pk=request.session.get('registraion_uid'))
    user.is_active = True
    user.save()
    login(request, user, 'allianceauth.authentication.backends.StateBackend')
    return redirect('authentication:dashboard')

Then in your project's urls.py file you'd add an entry before the include line like:

urlpatterns = [
    url(r'^account/register/$', complete_registration, name='registration_register'),
    url(r'', include(urls)),
]

This would replace the email entry form view with your custom view which immediately activates users even without an email.

I'm not inclined to add settings for everyone's edge case - the auth project structure of v2 allows you to override anything about allianceauth just like any other django app out there.

@mcmilj
Copy link

mcmilj commented May 14, 2018

While it isn't recommended, I have done this and have not noticed any side-effects with the services that are enabled on my deployment.

Simplest way is to make a new authentication backend:

from allianceauth.authentication.backends import StateBackend

class MyBackend(StateBackend):
    def create_user(self, token):
        user = super(MyBackend, self).create_user(self, token)
        user.is_active = True
        user.save()
        return user

and change the AUTHENTICATION_BACKENDS setting in settings/base.py to swap the StateBackend for MyBackend

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants