• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thnx for your reply Monroe!
[originally posted on jforum.net by Jochus]
 
Greenhorn
Posts: 5
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Carlo,
Thanks for posting the solution!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic