Author: phuong_vu
Date: 2010-11-12 01:48:59 -0500 (Fri, 12 Nov 2010)
New Revision: 5052
Removed:
exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/UILoginForm.java
Modified:
exo/portal/branches/3.1.x/component/web/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java
exo/portal/branches/3.1.x/component/web/src/main/java/org/exoplatform/web/login/PortalLoginController.java
exo/portal/branches/3.1.x/examples/extension/war/src/main/webapp/login/jsp/login.jsp
exo/portal/branches/3.1.x/examples/portal/war/src/main/webapp/login/jsp/login.jsp
exo/portal/branches/3.1.x/web/portal/src/main/webapp/groovy/portal/webui/UILoginForm.gtmpl
exo/portal/branches/3.1.x/web/portal/src/main/webapp/login/jsp/login.jsp
exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/login/UILoginForm.java
Log:
EXOGTN-86 There is invalid page when login successfully to the intranet after a failed
login
Modified:
exo/portal/branches/3.1.x/component/web/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java
===================================================================
---
exo/portal/branches/3.1.x/component/web/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java 2010-11-12
05:48:02 UTC (rev 5051)
+++
exo/portal/branches/3.1.x/component/web/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java 2010-11-12
06:48:59 UTC (rev 5052)
@@ -129,12 +129,12 @@
}
try
{
- req.setAttribute("org.gatein.portal.login.initial_uri", initialURI);
+
req.getSession(true).setAttribute("org.gatein.portal.login.initial_uri",
initialURI);
getServletContext().getRequestDispatcher("/login/jsp/login.jsp").include(req,
resp);
}
finally
{
- req.removeAttribute("org.gatein.portal.login.initial_uri");
+
req.getSession(true).removeAttribute("org.gatein.portal.login.initial_uri");
}
}
Modified:
exo/portal/branches/3.1.x/component/web/src/main/java/org/exoplatform/web/login/PortalLoginController.java
===================================================================
---
exo/portal/branches/3.1.x/component/web/src/main/java/org/exoplatform/web/login/PortalLoginController.java 2010-11-12
05:48:02 UTC (rev 5051)
+++
exo/portal/branches/3.1.x/component/web/src/main/java/org/exoplatform/web/login/PortalLoginController.java 2010-11-12
06:48:59 UTC (rev 5052)
@@ -73,12 +73,13 @@
// otherwise compute one
if (uri == null || uri.length() == 0)
{
- uri = req.getContextPath() + "/private/classic";
+ uri = req.getContextPath();
log.debug("No initial URI found, will use default " + uri + "
instead ");
}
else
{
log.debug("Found initial URI " + uri);
+
req.getSession(true).setAttribute("org.gatein.portal.login.initial_uri", uri);
}
// if we do have a remember me
Modified:
exo/portal/branches/3.1.x/examples/extension/war/src/main/webapp/login/jsp/login.jsp
===================================================================
---
exo/portal/branches/3.1.x/examples/extension/war/src/main/webapp/login/jsp/login.jsp 2010-11-12
05:48:02 UTC (rev 5051)
+++
exo/portal/branches/3.1.x/examples/extension/war/src/main/webapp/login/jsp/login.jsp 2010-11-12
06:48:59 UTC (rev 5052)
@@ -26,6 +26,7 @@
<%@ page import="java.util.ResourceBundle"%>
<%@ page import="org.exoplatform.web.login.InitiateLoginServlet"%>
<%@ page import="org.gatein.common.text.EntityEncoder"%>
+<%@ page import="javax.servlet.http.HttpSession"%>
<%@ page language="java" %>
<%@ page contentType="text/html; charset=utf-8" %>
<%
@@ -40,7 +41,9 @@
ResourceBundleService service = (ResourceBundleService)
portalContainer.getComponentInstanceOfType(ResourceBundleService.class);
ResourceBundle res = service.getResourceBundle(service.getSharedResourceBundleNames(),
request.getLocale()) ;
- String uri =
(String)request.getAttribute("org.gatein.portal.login.initial_uri");
+ HttpSession httpSession = request.getSession(true);
+ String uri =
(String)httpSession.getAttribute("org.gatein.portal.login.initial_uri");
+ httpSession.removeAttribute("org.gatein.portal.login.initial_uri");
Cookie cookie = new Cookie(InitiateLoginServlet.COOKIE_NAME, "");
cookie.setPath(request.getContextPath());
Modified:
exo/portal/branches/3.1.x/examples/portal/war/src/main/webapp/login/jsp/login.jsp
===================================================================
---
exo/portal/branches/3.1.x/examples/portal/war/src/main/webapp/login/jsp/login.jsp 2010-11-12
05:48:02 UTC (rev 5051)
+++
exo/portal/branches/3.1.x/examples/portal/war/src/main/webapp/login/jsp/login.jsp 2010-11-12
06:48:59 UTC (rev 5052)
@@ -26,6 +26,7 @@
<%@ page import="java.util.ResourceBundle"%>
<%@ page import="org.exoplatform.web.login.InitiateLoginServlet"%>
<%@ page import="org.gatein.common.text.EntityEncoder"%>
+<%@ page import="javax.servlet.http.HttpSession"%>
<%@ page language="java" %>
<%@ page contentType="text/html; charset=utf-8" %>
<%
@@ -40,7 +41,9 @@
ResourceBundleService service = (ResourceBundleService)
portalContainer.getComponentInstanceOfType(ResourceBundleService.class);
ResourceBundle res = service.getResourceBundle(service.getSharedResourceBundleNames(),
request.getLocale()) ;
- String uri =
(String)request.getAttribute("org.gatein.portal.login.initial_uri");
+ HttpSession httpSession = request.getSession(true);
+ String uri =
(String)httpSession.getAttribute("org.gatein.portal.login.initial_uri");
+ httpSession.removeAttribute("org.gatein.portal.login.initial_uri");
Cookie cookie = new Cookie(InitiateLoginServlet.COOKIE_NAME, "");
cookie.setPath(request.getContextPath());
Modified:
exo/portal/branches/3.1.x/web/portal/src/main/webapp/groovy/portal/webui/UILoginForm.gtmpl
===================================================================
---
exo/portal/branches/3.1.x/web/portal/src/main/webapp/groovy/portal/webui/UILoginForm.gtmpl 2010-11-12
05:48:02 UTC (rev 5051)
+++
exo/portal/branches/3.1.x/web/portal/src/main/webapp/groovy/portal/webui/UILoginForm.gtmpl 2010-11-12
06:48:59 UTC (rev 5052)
@@ -7,7 +7,7 @@
jsmanager.addCustomizedOnLoadScript('document.getElementById("UIPortalComponentLogin").username.focus();');
HttpSession session = rcontext.getRequest().getSession();
String requestPath = rcontext.getRequestContextPath() + "/private/" +
rcontext.getPortalOwner();
- session.setAttribute("initialURI", requestPath);
+ //session.setAttribute("initialURI", requestPath);
%>
<div class="UILoginForm">
<div class="LoginDecorator">
@@ -22,22 +22,20 @@
<div class="MiddleRightLoginDecorator">
<div class="LoginDecoratorBackground">
<div class="LoginDetailBox">
- <% uiform.begin(); %>
- <!--<form class="UIForm" id="$uicomponent.id"
name="loginForm" action="<%= rcontext.getRequestContextPath() +
"/login"%>" method="post" style="margin: 0px;">
- <input type="hidden" name="<%= uiform.ACTION %>"
value=""/>-->
- <input type="hidden" name="initialURI"
value="<%=session.getAttribute("initialURI"); %>"/>
+ <form class="UIForm" id="$uicomponent.id"
name="loginForm" action="<%= rcontext.getRequestContextPath() +
"/login"%>" method="post" style="margin: 0px;">
+ <input type="hidden" name="initialURI"
value="<%=requestPath%>"/>
<div class="VerticalLayout">
<table class="UIFormGrid">
<tr class="UserNameField">
<td
class="FieldLabel"><%=_ctx.appRes("UILoginForm.label.UserName")%></td>
- <td><% uiform.renderChild(0)%></td>
+ <td><input class="UserName"
name="username"/></td>
</tr>
<tr class="PasswordField" id="UIPortalLoginFormControl"
onkeypress="eXo.portal.UIPortalControl.onEnterPress(event)">
<td
class="FieldLabel"><%=_ctx.appRes("UILoginForm.label.password")%></td>
- <td><% uiform.renderChild(1)%></td>
+ <td><input class="Password" type="password"
name="password"/></td>
</tr>
<tr class="RememberField"
onkeypress="eXo.portal.UIPortalControl.onEnterPress(event)">
- <td class="FieldLabel"><%
uiform.renderChild(2)%></td>
+ <td class="FieldLabel"><input type="checkbox"
class="checkbox" value="true"
name="rememberme"/></td>
<td><%=_ctx.appRes("UILoginForm.label.RememberOnComputer")%></td>
</tr>
</table>
@@ -69,7 +67,7 @@
</table>
</div>
</div>
- <%uiform.end()%>
+ </form>
</div>
</div>
</div>
@@ -84,7 +82,6 @@
<script>
function login(ele) {
var formEle = eXo.core.DOMUtil.findAncestorByTagName(ele,'form');
- formEle.action = eXo.env.portal.context + "/login";
formEle.submit();
}
</script>
Modified: exo/portal/branches/3.1.x/web/portal/src/main/webapp/login/jsp/login.jsp
===================================================================
--- exo/portal/branches/3.1.x/web/portal/src/main/webapp/login/jsp/login.jsp 2010-11-12
05:48:02 UTC (rev 5051)
+++ exo/portal/branches/3.1.x/web/portal/src/main/webapp/login/jsp/login.jsp 2010-11-12
06:48:59 UTC (rev 5052)
@@ -26,6 +26,7 @@
<%@ page import="java.util.ResourceBundle"%>
<%@ page import="org.exoplatform.web.login.InitiateLoginServlet"%>
<%@ page import="org.gatein.common.text.EntityEncoder"%>
+<%@ page import="javax.servlet.http.HttpSession"%>
<%@ page language="java" %>
<%
String contextPath = request.getContextPath() ;
@@ -44,8 +45,9 @@
cookie.setMaxAge(0);
response.addCookie(cookie);
- String uri =
(String)request.getAttribute("org.gatein.portal.login.initial_uri");
-
+ HttpSession httpSession = request.getSession(true);
+ String uri =
(String)httpSession.getAttribute("org.gatein.portal.login.initial_uri");
+ httpSession.removeAttribute("org.gatein.portal.login.initial_uri");
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html; charset=UTF-8");
%>
Deleted:
exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/UILoginForm.java
===================================================================
---
exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/UILoginForm.java 2010-11-12
05:48:02 UTC (rev 5051)
+++
exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/UILoginForm.java 2010-11-12
06:48:59 UTC (rev 5052)
@@ -1,92 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.portal.webui;
-
-import org.exoplatform.portal.application.PortalRequestContext;
-import org.exoplatform.portal.webui.portal.UIPortal;
-import org.exoplatform.portal.webui.util.Util;
-import org.exoplatform.portal.webui.workspace.UIMaskWorkspace;
-import org.exoplatform.services.organization.OrganizationService;
-import org.exoplatform.web.application.ApplicationMessage;
-import org.exoplatform.webui.config.annotation.ComponentConfig;
-import org.exoplatform.webui.config.annotation.EventConfig;
-import org.exoplatform.webui.core.lifecycle.UIFormLifecycle;
-import org.exoplatform.webui.event.Event;
-import org.exoplatform.webui.event.EventListener;
-import org.exoplatform.webui.event.Event.Phase;
-import org.exoplatform.webui.exception.MessageException;
-import org.exoplatform.webui.form.UIForm;
-import org.exoplatform.webui.form.UIFormStringInput;
-
-import java.net.URLEncoder;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-/**
- * Created by The eXo Platform SARL
- * Author : Nhu Dinh Thuan
- * nhudinhthuan(a)exoplatform.com
- * Jul 11, 2006
- */
-@ComponentConfig(lifecycle = UIFormLifecycle.class, template =
"system:/groovy/portal/webui/UILoginForm.gtmpl", events = {
- @EventConfig(listeners = UILoginForm.SigninActionListener.class),
- @EventConfig(phase = Phase.DECODE, listeners =
UIMaskWorkspace.CloseActionListener.class)})
-public class UILoginForm extends UIForm
-{
-
- public UILoginForm() throws Exception
- {
- addUIFormInput(new UIFormStringInput("username", "username",
null)).addUIFormInput(
- new UIFormStringInput("password", "password",
null).setType(UIFormStringInput.PASSWORD_TYPE));
- }
-
- static public class SigninActionListener extends EventListener<UILoginForm>
- {
-
- public void execute(Event<UILoginForm> event) throws Exception
- {
- UILoginForm uiForm = event.getSource();
- String username = uiForm.getUIStringInput("username").getValue();
- String password = uiForm.getUIStringInput("password").getValue();
-
- OrganizationService orgService =
uiForm.getApplicationComponent(OrganizationService.class);
- boolean authentication = orgService.getUserHandler().authenticate(username,
password);
- if (!authentication)
- {
- throw new MessageException(new
ApplicationMessage("UILoginForm.msg.Invalid-account", null));
- }
-
- PortalRequestContext prContext = Util.getPortalRequestContext();
- HttpServletRequest request = prContext.getRequest();
- HttpSession session = request.getSession();
- session.setAttribute("authentication.username", username);
- session.setAttribute("authentication.password", password);
- UIPortal uiPortal = Util.getUIPortal();
- prContext.setResponseComplete(true);
- String portalName = uiPortal.getName();
- portalName = URLEncoder.encode(portalName, "UTF-8");
- String redirect = request.getContextPath() + "/private/" + portalName
+ "/";
- prContext.getResponse().sendRedirect(redirect);
- }
-
- }
-
-}
Modified:
exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/login/UILoginForm.java
===================================================================
---
exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/login/UILoginForm.java 2010-11-12
05:48:02 UTC (rev 5051)
+++
exo/portal/branches/3.1.x/webui/portal/src/main/java/org/exoplatform/portal/webui/login/UILoginForm.java 2010-11-12
06:48:59 UTC (rev 5052)
@@ -20,17 +20,13 @@
package org.exoplatform.portal.webui.login;
import org.exoplatform.portal.webui.workspace.UIMaskWorkspace;
-import org.exoplatform.web.login.InitiateLoginServlet;
+import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.config.annotation.ComponentConfig;
import org.exoplatform.webui.config.annotation.EventConfig;
-import org.exoplatform.webui.core.lifecycle.UIFormLifecycle;
+import org.exoplatform.webui.core.UIComponent;
import org.exoplatform.webui.event.Event;
-import org.exoplatform.webui.event.EventListener;
import org.exoplatform.webui.event.Event.Phase;
-import org.exoplatform.webui.form.UIForm;
-import org.exoplatform.webui.form.UIFormCheckBoxInput;
-import org.exoplatform.webui.form.UIFormStringInput;
-import org.exoplatform.webui.form.validator.MandatoryValidator;
+import org.exoplatform.webui.event.EventListener;
/**
* Created by The eXo Platform SARL
@@ -38,58 +34,15 @@
* nhudinhthuan(a)exoplatform.com
* Jul 11, 2006
*/
-@ComponentConfig(lifecycle = UIFormLifecycle.class, template =
"system:/groovy/portal/webui/UILoginForm.gtmpl", events = {
- // @EventConfig(listeners = UILoginForm.SigninActionListener.class),
+@ComponentConfig(template = "system:/groovy/portal/webui/UILoginForm.gtmpl",
events = {
@EventConfig(phase = Phase.DECODE, listeners =
UIMaskWorkspace.CloseActionListener.class),
@EventConfig(phase = Phase.DECODE, listeners =
UILoginForm.ForgetPasswordActionListener.class)})
-public class UILoginForm extends UIForm
+public class UILoginForm extends UIComponent
{
- final static String USER_NAME = "username";
-
- final static String PASSWORD = "password";
-
public UILoginForm() throws Exception
{
- addUIFormInput(new UIFormStringInput(USER_NAME, USER_NAME,
null).addValidator(MandatoryValidator.class))
- .addUIFormInput(
- new UIFormStringInput(PASSWORD, PASSWORD,
null).setType(UIFormStringInput.PASSWORD_TYPE).addValidator(
- MandatoryValidator.class));
- addUIFormInput(new
UIFormCheckBoxInput<String>(InitiateLoginServlet.COOKIE_NAME,
- InitiateLoginServlet.COOKIE_NAME, Boolean.TRUE.toString()));
}
- static public class SigninActionListener extends EventListener<UILoginForm>
- {
-
- public void execute(Event<UILoginForm> event) throws Exception
- {
- // UILoginForm uiForm = event.getSource();
- // String username = uiForm.getUIStringInput(USER_NAME).getValue();
- // String password = uiForm.getUIStringInput(PASSWORD).getValue();
- // OrganizationService orgService =
uiForm.getApplicationComponent(OrganizationService.class);
- // boolean authentication =
orgService.getUserHandler().authenticate(username, password);
- // if(!authentication){
- // throw new MessageException(new
ApplicationMessage("UILoginForm.msg.Invalid-account", null));
- // }
- // PortalRequestContext prContext = Util.getPortalRequestContext();
- // HttpServletRequest request = prContext.getRequest();
- // HttpSession session = request.getSession();
- // session.setAttribute("authentication.username", username);
- // session.setAttribute("authentication.password", password);
- // UIPortal uiPortal = Util.getUIPortal();
- // prContext.setResponseComplete(true);
- // String portalName = uiPortal.getName() ;
- // HttpServletRequestWrapper wrapper = new
HttpServletRequestWrapper(request) ;
- // wrapper.getParameterMap().put("username", username) ;
- // wrapper.getParameterMap().put("password", password) ;
- // portalName = URLEncoder.encode(portalName, "UTF-8") ;
- // String redirect = request.getContextPath() + "/private/" +
portalName + "/";
- // prContext.getResponse().sendRedirect(redirect);
- }
-
- }
-
- //TODO: dang.tung - forget password
static public class ForgetPasswordActionListener extends
EventListener<UILoginForm>
{
public void execute(Event<UILoginForm> event) throws Exception
@@ -100,4 +53,16 @@
event.getRequestContext().addUIComponentToUpdateByAjax(uiLogin);
}
}
+
+ @Override
+ public void processDecode(WebuiRequestContext context) throws Exception
+ {
+ super.processDecode(context);
+ String action = context.getRequestParameter(context.getActionParameterName());
+ Event<UIComponent> event = createEvent(action, Event.Phase.DECODE, context);
+ if (event != null)
+ {
+ event.broadcast();
+ }
+ }
}