File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JForum and the fly likes Automatically redirect to login page is user is not logged in? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JForum
Bookmark "Automatically redirect to login page is user is not logged in?" Watch "Automatically redirect to login page is user is not logged in?" New topic
Author

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

Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
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

Joined: Apr 22, 2012
Posts: 17424
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

Joined: Apr 22, 2012
Posts: 17424
Thnx for your reply Monroe!
[originally posted on jforum.net by Jochus]
Carlo Benincasa
Greenhorn

Joined: Nov 22, 2012
Posts: 5
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30299
    
150

Carlo,
Thanks for posting the solution!


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Automatically redirect to login page is user is not logged in?