def do(self, action_context, view, email, *args, **kwargs):
# Reset token
user = action_context.extra_context.get('user')
if user:
refresh_password_reset_token(user)
url = reverse('auth:reset-password', kwargs={
'user_id': user.id,
'uuid': str(user.password_reset_token)})
# Prepare the full url (get the domain from the asked
# wiggum entrypoint)
domain = action_context.request.META.get('HTTP_HOST')
scheme = 'http' if settings.DEBUG else "https"
# Get redirection uri
params = QueryDict(mutable=True)
redirect_uri = action_context.extra_context.get("redirect_uri")
if redirect_uri:
params[settings.REDIRECT_URL_VALID_PARAMS[0]] = redirect_uri
url = urllib.parse.ParseResult(scheme=scheme,
netloc=domain,
path=url,
params="",
query=params.urlencode(),
fragment="").geturl()
action_context.extra_context['pass_reset_url'] = url
logger.debug("Password recover url created: {0}".format(url))
return super().do(action_context, view, email, *args, **kwargs)
评论列表
文章目录