3👍
✅
You can use the Signer class to achieve this. i.e.
from django.core.signing import Signer
signer = Signer()
signed_value = signer.sign(profile.user.email)#gives 'email@email.com:signed_things', extract signed_things'
key = ''.join(signed_value.split(':')[1:])
#send out key as part of url
You can then store the key with the user profile for instance. When the link is requested, you can do something like the following:
profile = get_object_or_404(UserProfile, key=key)
signer = Signer()
if signer.unsign('{0}:{1}'.format(profile.user.email, key)) == profile.user.email:
profile.verified = True
👤keni
Source:stackexchange.com