Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Automatically redirect to login page is user is not logged in?

 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

When a user is trying to access a board based on a URL (e.g.: http://MYDOMAIN/jforum/forums/show/2.page), the user is getting the following warning:



So the user thinks: "Hmm, I don't have enough permissions to access this board". The real thing is: the user just didn't log in before trying to access the board.

So, is it possible to change a setting so we can redirect the user to the login page if he is trying to reach a board directly?

Thanks in advance,
Jochen
[originally posted on jforum.net by Jochus]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for the delay... on vacation last week with limited i-net access.

It depends on if you want anonymous access to the forums or not. What is happening is that the request is getting logged in as the anonymous user, which does not have access. If the user is coming via the index they should not see this link.

That said, the easiest thing to do would be to change the message text for the ForumListing.denied property in the language properties you are supporting. You can change the text to be something like:

Sorry, you don't have access to this forum. You may need to login above to access it.

If you don't want anonymous access to your forums, you can probably just modify the header.htm template to check if the logged property is false and forward them to the login screen using some Freemarker (freemarker.com) script statements above the <html> tag.
[originally posted on jforum.net by monroe]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thnx for your reply Monroe!
[originally posted on jforum.net by Jochus]
 
Carlo Benincasa
Greenhorn
Posts: 5
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
i have found control <#if !logged && !sso> that permitted identification if users are logged or not.
But how i do the redirect?

Thanks for reply.
Carlo Benincasa



Edit:
Solution:


Copy and paste file header.htm and rename header2.htm

In header.htm after this line:

<style type="text/css">@import url( ${contextPath}/templates/${templateName}/styles/${language}.css?${startupTime} );</style>


insert this:

<#if !logged && !sso>
<script language="javascript">
location.replace("http://localhost:8080/jforum/user/login.page");
</script>
</#if>


edit with notepad++ or text editor the file forum_login.htm and replace first line with .
That's all.
Save and try.

Bye
Carlo Benincasa
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34837
369
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carlo,
Thanks for posting the solution!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic