HTML page accessible only to logged in users
4 posters
Page 1 of 1
HTML page accessible only to logged in users
Hello, I'd like to ask - is it possible to make HTML pages only visible to logged in users?
Re: HTML page accessible only to logged in users
Good evening!
This issue has been discussed in this topic.
If you need more detailed instructions, please specify:
1) link to the HTML page.
2) what do you want to make available to guests and what do you want to make available to registered users
This issue has been discussed in this topic.
If you need more detailed instructions, please specify:
1) link to the HTML page.
2) what do you want to make available to guests and what do you want to make available to registered users
Razor12345- Support Moderator
- Posts : 1586
Reputation : 268
Language : Ukr, Rus, Eng
Location : Ukraine
skouliki and TonnyKamper like this post
Re: HTML page accessible only to logged in users
Razor12345 wrote:Good evening!
This issue has been discussed in this topic.
If you need more detailed instructions, please specify:
1) link to the HTML page.
2) what do you want to make available to guests and what do you want to make available to registered users
Thank you for answering I looked at the topic and tried using that code, but it didn't work for me but then again, I might've used it wrongly could you please specify how to use that code, just to make sure I didn't make a mistake?
Basically, that is what I'd like to do - I want my HTML pages and their content to be only accessible to users who're logged in. For guests it could say something like "You don't have a permission to view this page" or so.
I deleted the page after I couldn't make it inaccessible to guests
Re: HTML page accessible only to logged in users
Coucou @Ayushka
that is actually possible, if you select to use the header and footer of the forum for the HTML page
Despite being possible, it is a really weak solution, so any visitor only has to disable javascript to access the content easily
I don't know if you still want to try in this way
If so, please provide a demo HTML page so that I can provide you a code based on your forum and forum version
that is actually possible, if you select to use the header and footer of the forum for the HTML page
Despite being possible, it is a really weak solution, so any visitor only has to disable javascript to access the content easily
I don't know if you still want to try in this way
If so, please provide a demo HTML page so that I can provide you a code based on your forum and forum version
Re: HTML page accessible only to logged in users
Ayushka wrote:
Thank you for answering I looked at the topic and tried using that code, but it didn't work for me but then again, I might've used it wrongly could you please specify how to use that code, just to make sure I didn't make a mistake?
Basically, that is what I'd like to do - I want my HTML pages and their content to be only accessible to users who're logged in. For guests it could say something like "You don't have a permission to view this page" or so.
I deleted the page after I couldn't make it inaccessible to guests
As Niko said above, this code will work if you enable the forum header and footer to be displayed on the HTML page
If you don't use a forum header and footer, we need an extra action - we load the data from the forum homepage and check if the "Logout" button is available. If it is, we show the content to the user. If not, we show the content to the guest.
You still haven't specified the forum address and version, so this code is like a demo for Invision.
- Code:
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" /><style>
.users {
background-color: green;
border: 3px solid green;
display: none;
}
.guests {
display:none;
background-color: blue;
border: 3px solid blue;
}
</style> <title>Заголовок страницы</title>
<div class="guests">
<h1>
<span class="text__guest">Hello, guest! You need to register or log in to see this page.</span>
</h1>
</div>
<div class="users">
<h1>
<span class="text__user">Hello, user!You see this page because you are authorised</span>
</h1>
</div><script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script>
window.addEventListener('load', function() {
let url = location.origin;
$.ajax({
url: url,
method: "GET",
data: 'a.mainmenu',
dataType: "html",
success: function (data) {
let div = document.createElement('div');
div.innerHTML = data;
let find_el = div.querySelector('#submenu');
let checkAuth = find_el.querySelector("a#logout");
if (checkAuth) {
document.querySelector('div.users').style.display = 'block';
} else {
document.querySelector('div.guests').style.display = 'block';
}
},
error: function (xhr, status, error) {
console.log("AJAX request error:" + error);
}
});
});
</script>
Result:
Text on the HTML page if I log out of my account
For me to be able to make this code to fit your forum version, please specify the forum address, the HTML page address and the forum version.
Razor12345- Support Moderator
- Posts : 1586
Reputation : 268
Language : Ukr, Rus, Eng
Location : Ukraine
TonnyKamper likes this post
Re: HTML page accessible only to logged in users
Wow, thank you both so much for explaining this to me!
On my HTML pages I don't want to have the forum header and footer displayed if possible - here's the link for the html page I just created for this purpose: click, forum version should be ModernBB
On my HTML pages I don't want to have the forum header and footer displayed if possible - here's the link for the html page I just created for this purpose: click, forum version should be ModernBB
Re: HTML page accessible only to logged in users
- Code:
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" /><style>
.users {
background-color: green;
border: 3px solid green;
display: none;
}
.guests {
display:none;
background-color: blue;
border: 3px solid blue;
}
</style> <title>Заголовок страницы</title>
<div class="guests">
<h1>
<span class="text__guest">Hello, guest! You need to register or log in to see this page.</span>
</h1>
</div>
<div class="users">
<h1>
<span class="text__user">Hello, user!You see this page because you are authorised</span>
</h1>
</div><script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script>
window.addEventListener('load', function() {
let url = location.origin;
$.ajax({
url: url,
method: "GET",
data: 'ul#modernbb-nav-menu',
dataType: "html",
success: function (data) {
let div = document.createElement('div');
div.innerHTML = data;
console.log(div);
let find_el = div.querySelector('ul#modernbb-nav-menu');
let checkAuth = find_el.querySelector("li a#logout");
if (checkAuth) {
document.querySelector('div.users').style.display = 'block';
} else {
document.querySelector('div.guests').style.display = 'block';
}
},
error: function (xhr, status, error) {
console.log("AJAX request error:" + error);
}
});
});
</script>
Insert anything you want to show guests on the HTML page into this container
- Code:
<div class="guests">
...
</div>
Insert anything you want to show users on the HTML page into this container
- Code:
<div class="users">
...
</div>
Razor12345- Support Moderator
- Posts : 1586
Reputation : 268
Language : Ukr, Rus, Eng
Location : Ukraine
TonnyKamper, poesia-verses and Ayushka like this post
Re: HTML page accessible only to logged in users
Problem solved & topic archived.
|
Similar topics
» How do I create things which can only be viewed by either logged in or logged out users?
» Says 0 users online when I'm not logged in and when others are not
» [Help] HTML Page: Space between Header and top of page.
» How to Embed a Google Docs Form into an HTML page using HTML Pages Management
» Make code for guest/logged out users
» Says 0 users online when I'm not logged in and when others are not
» [Help] HTML Page: Space between Header and top of page.
» How to Embed a Google Docs Form into an HTML page using HTML Pages Management
» Make code for guest/logged out users
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum