Answer the question
In order to leave comments, you need to log in
How to implement email activation?
Hello.
I want to write a small registration with activation by email (which expires after N period of time).
Previously, I always used Django-registration-redux for such purposes and it completely suited me, but now I can’t do this because I don’t know how to bind Django-registration-redux to the REST API written in Django Rest Framework.
Essence:
You need to register a user (inactive) and a day to confirm your account by sending an activation email.
I know that the confirmation time can be set in settings.py: ACCOUNT_ACTIVATION_DAYS = 1
Problem:
How to create an inactive user in a view (using functions), generate an activation token for him and send an email?
Answer the question
In order to leave comments, you need to log in
maybe I didn’t understand the question correctly, but, in my opinion, everything is quite simple:
in the database, the kryzhyk is an active \ inactive token and the date of creation of the token
is turned off; the user checks the kryzhyk from the database; creating a token, if more than a day ago we generate a new one, write it to the database, send a new message to the client
store tokens in the database. and then constantly go there, find out something, then constantly clean up this database, and so on and so forth. This is a super rotten approach.
encode the necessary information (date of generation of the token, and its expiration time) directly into the token.
then -> all you need is to decode the token and compare the date received from the token with the current one.
and all these bases with tokens you don’t fucking need, bazaar!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question