G
G
Germs2019-05-17 08:48:26
Django
Germs, 2019-05-17 08:48:26

Python. Django. How to limit the user access to certain pages through the search bar?

Python. Django. The password recovery process via email has several html pages, the first is password-reset, which can be accessed through the login page, on this page you need to enter an email, after which the user is redirected to a page where he is informed about the instructions, but this page can be accessed through search string, knowing the page address. How to privatize it or restrict access to it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2019-05-17
@Germs

referer = request.META.get('HTTP_REFERER')
if referer != reverse('accounts:reset'):
    raise PermissionDenied

K
Konstantin Malyarov, 2019-05-17
@Konstantin18ko

def password_reset(request):
    if request.user.is_authenticated:
        return render(request, 'page/password_reset.html', locals())
    else:
        return redirect('/page/login/', locals())

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question