Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework email confirmation #38

Open
merwok opened this issue Oct 10, 2018 · 3 comments · May be fixed by #44
Open

Rework email confirmation #38

merwok opened this issue Oct 10, 2018 · 3 comments · May be fixed by #44
Assignees
Milestone

Comments

@merwok
Copy link
Contributor

merwok commented Oct 10, 2018

Issues in current email confirmation code:

if self.email_confirmation_class is None:
raise MissingSetting('email_confirmation_string')
confirmation = self.email_confirmation_class.objects.create(user=user)
if get_setting('email_confirmation_send_email', True):
email_field = user.get_email_field_name()
send_email(request, user, getattr(user, email_field), confirmation)

  1. Email confirmation should be optional (for projects that want to accept signups immediately, or validate the email with other methods). At the moment there is a setting for this, but a test fails if no EmailConfirmation class is defined (caused by Impossible to use login view without configuring signup view #11).

  2. For projects where the website (JS dynamic site) and the API have separate domain names, we can’t use routes and reverse to create the URL in the email; another function should be used to generate frontend URL (example below).

  3. Provide an API view to receive the confirmation token sent by the frontend.

  4. If confirmation fails, the user can’t sign up again with the same address. We could change signup to use get_or_create; add an endpoint to re-send the email; punt until Generate email tokens without using the database #19 is solved; something else.

@merwok merwok added the feature label Oct 10, 2018
@merwok merwok changed the title Alternative to email confirmation: short numerical code Rework email confirmation Oct 16, 2018
@merwok
Copy link
Contributor Author

merwok commented Oct 16, 2018

Example of function to generate frontend URLs:

def reverse_landing(route, **kwargs):
    """Generate a landing (frontend) URL.

    This is useful to create links for email invitations or PDF generation,
    without hard-coding the frontend URL patterns in multiple locations.
    """
    routes = {
        'home': '/home',
        'todo-list': '/tasks',
        'todo-detail': '/tasks/{id}',
        'invite-detail': '/invite/{token}',
    }
    base_url = routes[route].format_map(kwargs)
    site_domain = settings.FRONTEND_DOMAIN
    return f'https://{site_domain}{base_url}'

Add a small template tag that calls this function and you can write your email template.

@merwok merwok self-assigned this Oct 17, 2018
@merwok merwok linked a pull request Oct 18, 2018 that will close this issue
@merwok merwok modified the milestones: v1.0, v0.10 Nov 9, 2018
merwok added a commit that referenced this issue Nov 10, 2018
Co-authored-by: Julien Labonté <[email protected]>
@merwok
Copy link
Contributor Author

merwok commented Nov 12, 2018

@just1602 I added item 4, what do you think would be cleaner?

@just1602
Copy link

We should definitively find a way to make the confirmation independent from the the signup process.

We should have two flows:

  • signup process which send an email after signin
  • a process that take an email and resend the confirmation email if we have this email in the database and the email isn't validated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants