[Logo] JForum - Powering Communities
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Top Downloads] Top Downloads   [Groups] Back to home page 
[Register] Register /  [Login] Login 

The final version of JForum 2.8.0 has been released with lots of improvements. Read all about it here

Adding static functions to html template RSS feed
Forum Index » Developer Forum
Author Message

Joined: 2014/3/6
Messages: 1
Hi folks,

My name is Omar I'm new to JForum.

I want to add a token to an htm template by calling a java static function. The token is meant to protect the form from Cross-Site Request Forgery (CSRF) attacks, and therefore needs to be generated dynamically.

I saw similar constructions in some htm templates and since normally htm/html pages do not allow to have dynamic components I assumed that this is a JForum feature.

What i did is put the following code into the htm file:
<input type="hidden" name="csrf" value="${TokenGenerator.generateToken()}" />

However when I run the code I get the following error:
Expression TokenGenerator is undefined on line 4, column 47 in custom/forum_login.htm.

I think I also need to define that function in some configuration file, however I have no clue how to do that.

Any help would be appreciated.

Joined: 2011/6/30
Messages: 230
It looks like I18n, so I guess you can put it in the prepareTemplateContext() method of ControllerUtils.java:
[code=java;first-line:91]public void prepareTemplateContext(final SimpleHash context, final ForumContext jforumContext)
context.put("I18n", I18n.getInstance());
context.put("TokenGenerator", TokenGenerator.getInstance());
Forum Index » Developer Forum
Go to:   
Mobile view
Powered by JForum 2.8.0-b1 © 2021 JForum Team • Maintained by Andowson Chang and Ulf Dittmer