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

Unsubscribe from email #337

Open
tonylampada opened this issue Oct 11, 2015 · 6 comments
Open

Unsubscribe from email #337

tonylampada opened this issue Oct 11, 2015 · 6 comments

Comments

@tonylampada
Copy link
Member

Emails sent from freedomsponsors should have an "unsubscribe" link.
Clicking on this link should take the user directly to email preferences, on edit profile page.

The tricky part is adding a security token that will allow the user to see that page without asking for login/password.

@IuryAlves
Copy link

I Will do it !!!

doit

@tonylampada
Copy link
Member Author

Hahahaha thanks!

DO IT!!

@IuryAlves
Copy link

@tonylampada Finally manage to run the application, the postgres was malconfigured on Fedora.
Now going to the point. I am thinking of using django's db cache to store the security token.

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
        'LOCATION': 'my_cache_table',
    }
}

Is this ok? Or do you have another solution?

@IuryAlves
Copy link

from django.core.cache import cache

user_id = cache.get("hash")

@tonylampada

@iurisilvio
Copy link
Contributor

@IuryAlves Do not trust the cache. :) Maybe the user will click on this "Unsubscribe" link after this cache record is invalidated or someone will just flush the cache. If you send lots of emails, it consumes all the cache memory.

You must persist a token associated to the user in your database and send this token and the username (encrypted), maybe HMAC in "Unsubscribe" link.

This token must give access only to this "email preferences" page, don't use Django auth system to persist user session.

Some useful links:

http://lea.verou.me/2010/08/automatic-login-via-notification-emails/
http://stackoverflow.com/questions/4653903/instant-login-from-email-why-have-so-few-done-this
mozilla/persona-yahoo-bridge#193 (comment)

(This is obviously not @tonylampada answer, it is just how I'd do it.)

@IuryAlves
Copy link

@iurisilvio Yep, @tonylampada answer the same thing. Thanks for the links = )

In Django there is a module called signing to encrypt data as HMAC

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

No branches or pull requests

3 participants