Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
1186 Lượt xem

Hi everyone,


I need some help configuring a web page that requires user login. Specifically, on my landing page, I have a link that says "Try Our Service Free." When a site visitor clicks this link, I want to check if they are already logged in. If they are logged in, they should be taken to the restricted page. If not, they should be redirected to the login page.


Could anyone advise on how to set this up in a website builder app? 

Thank you!

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi

Use an if statement to check if the user is logged in. If logged in, redirect to the restricted page. If not, redirect to the login page.

Example :    if request.env.user and request.env.user.id != request.env.ref('base.public_user').id:

        return request.redirect('restricted page URL)

    else:

        return request.redirect('/web/login')


Hope it helps

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
4
thg 5 25
4082
2
thg 1 25
2251
4
thg 1 25
4375
0
thg 11 24
1685
1
thg 11 24
2486