Fórum

Liferay set session on specific web content structure

Haider Ghaleb, modificado 11 Anos atrás.

Liferay set session on specific web content structure

New Member Postagens: 10 Data de Entrada: 25/07/12 Postagens Recentes
How can i set page session on a specific web content structure so if i assign any page with this specific structure, it will check if the session is there, if not it will appear password input, and user should insert the password.

In the page structure also i want to add next, finish and cancel buttons, so if i finish or cancel it will destroy the session and if a user is trying to access the page, he will be for the password.

I'm trying to do it from the web content template .VM

That's the code i made till now

Structure code:

<?xml version="1.0"?>

<root>
<dynamic-element name="classified" type="list" index-type="" repeatable="false">
<dynamic-element name="Yes" type="1" index-type="" repeatable="false"></dynamic-element>
<dynamic-element name="No" type="0" index-type="" repeatable="false"/>
</dynamic-element>
<dynamic-element name="content" type="text_area" index-type="" repeatable="false"/>
</root>

Template code:

#if($classified.getData() == "1")
#if($request.parameters.get('password') == "1234")
<p>$content.getData()</p>
#else
<h2>This is the second authentication verification</h2>
<p>Please enter you second password</p>
#set ($url = $request.get('render-url'))
<form action="$url" name="auth" method="POST">
<label name="password">Password<span style="color:red">*</span></label>
<input type="password" name="password" />
<input type="submit" />
</form>
#if($request.parameters.get('password') != "1234")
<p>Please enter correct password</p>
#end
#end
#else
<h2>This is not a classified page</h2>
#end


How can i make this idea.
thumbnail
Ray Augé, modificado 11 Anos atrás.

RE: Liferay set session on specific web content structure

Liferay Legend Postagens: 1197 Data de Entrada: 08/02/05 Postagens Recentes
You can't check to see if a the session is there for login, because in a Java web app, there is always a session, even when not authenticated.

However, if what you want is to identify if the client is authenticated, you only need to do:

#if ($permissionChecker.isSignedIn())
    .. do something cool
#else
    .. hey, you must sign in!
#end


However, make sure to uncheck "Cacheable" for your template, otherwise it won't be request scoped execution.
Haider Ghaleb, modificado 11 Anos atrás.

RE: Liferay set session on specific web content structure

New Member Postagens: 10 Data de Entrada: 25/07/12 Postagens Recentes
Thank you Ray. What i'm trying to do is

The user will have to sign in the system at first then he want to access this specific page let's say it's name is "Restricted", once he click on it, it will ask him to enter his second password, if the password is right and for now it's a constant value "1234". It will start a new session let's say "second_password" and this session can be manipulated in specific pages which only can read session "second_password". Inside the page, i want to have finish process, once i click on it, session "second_password" will be destroyed and if he tried to access "Restricted" page again he will be asked for the password.

I made with the velocity the asking for the password, by defining structure and template for the web content.



The code is up in the first message.

What do you think i should do? i would really appreciate if you can help me in this.