简体   繁体   English

设置有关特定Liferay Web内容结构的会话

[英]Set session on specific Liferay Web-content Structure

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 or not and if not it will ask for password input. 如何在特定的Web内容结构上设置页面会话,因此,如果我用该特定结构分配任何页面,它将检查该session是否存在,如果不存在,它将要求输入密码。 The user should then insert the password. 然后,用户应输入密码。

In the page structure I also want to add Next , Finish and Cancel buttons, so if I finish or cancel it will destroy the session. 在页面结构中,我还想添加NextFinishCancel按钮,因此,如果我完成或取消,它将破坏会话。 And if after this the user is trying to access the page, he will be again asked for the password. 如果在此之后用户尝试访问该页面,则将再次要求他输入密码。

I'm trying to do it from the Web-content template *.VM . 我正在尝试从Web内容模板*.VM做到这*.VM

Following is the code I have 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 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 your 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 work. 我如何使这个想法可行。

In my opinion a better approach for this is to write a servlet that will check for the user session and that, if there is no session, will redirect automatically to a dedicated page with a login portlet. 在我看来,一种更好的方法是编写一个Servlet ,它会检查用户会话,如果没有会话,它将自动重定向到带有登录Portlet的专用页面。 Authenticating the user really isn't the task of a Velocity script... 验证用户确实不是Velocity脚本的任务...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM