def lost_password_recover(request, username, days, hash): user = get_object_or_404(User, username=username) if utils.hash_is_valid(username, days, hash): user.backend = "django.contrib.auth.backends.ModelBackend" auth.login(request, user) return HttpResponseRedirect("/%s/password/" % username) else: return render(request, "lost_password.html", {"message": "That was not a valid account recovery link"})
def get(self, request, *args, **kwargs): username = kwargs['username'] user = get_object_or_404(User, username=username) if utils.hash_is_valid(username, kwargs['days'], kwargs['hash']): user.backend='django.contrib.auth.backends.ModelBackend' auth.login(request, user) url = reverse('edit_password', kwargs={'username': username}) return redirect(url) return super(LostPasswordRecoverView, self).get(request, *args, **kwargs)