oncall-engine/engine/apps/sendgridapp/verification_token.py
Michael Derynck 6b40f95033 World, meet OnCall!
Co-authored-by: Eve832 <eve.meelan@grafana.com>
    Co-authored-by: Francisco Montes de Oca <nevermind89x@gmail.com>
    Co-authored-by: Ildar Iskhakov <ildar.iskhakov@grafana.com>
    Co-authored-by: Innokentii Konstantinov <innokenty.konstantinov@grafana.com>
    Co-authored-by: Julia <ferril.darkdiver@gmail.com>
    Co-authored-by: maskin25 <kengurek@gmail.com>
    Co-authored-by: Matias Bordese <mbordese@gmail.com>
    Co-authored-by: Matvey Kukuy <motakuk@gmail.com>
    Co-authored-by: Michael Derynck <michael.derynck@grafana.com>
    Co-authored-by: Richard Hartmann <richih@richih.org>
    Co-authored-by: Robby Milo <robbymilo@fastmail.com>
    Co-authored-by: Timur Olzhabayev <timur.olzhabayev@grafana.com>
    Co-authored-by: Vadim Stepanov <vadimkerr@gmail.com>
    Co-authored-by: Yulia Shanyrova <yulia.shanyrova@grafana.com>
2022-06-03 08:09:47 -06:00

20 lines
856 B
Python

"""Based on example https://simpleisbetterthancomplex.com/tutorial/2016/08/24/how-to-create-one-time-link.html"""
from django.conf import settings
from django.contrib.auth.tokens import PasswordResetTokenGenerator
class EmailVerificationTokenGenerator(PasswordResetTokenGenerator):
# There are the default setting of PASSWORD_RESET_TIMEOUT_DAYS = 3 (days)
key_salt = "EmailVerificationTokenGenerator" + settings.TOKEN_SALT
secret = settings.TOKEN_SECRET
def _make_hash_value(self, user, timestamp):
team_datetime_timestamp = (
"" if user.teams.first() is None else user.teams.first().datetime.replace(microsecond=0, tzinfo=None)
)
return str(user.pk) + str(timestamp) + str(team_datetime_timestamp) + str(user.email_verified)
email_verification_token_generator = EmailVerificationTokenGenerator()