Issue 18077: Changes in Login page to add the sign-in button
authorIván Perdomo <ivan.perdomo@openbravo.com>
Fri, 29 Jul 2011 09:52:21 +0200
changeset 13342 de5d084560bb
parent 13341 39cca0f426d8
child 13343 e7834578f484
Issue 18077: Changes in Login page to add the sign-in button
- New feature, the login process can add a new startup message that will be
shown as a dialog box
- Moved the errorMsgTitle and errorMsgContent to be in the html page instead
of created dynamically using JavaScript
- Show the 'Sign in using: G' when the module is available
src/index.jsp
src/org/openbravo/erpCommon/security/Login.html
src/org/openbravo/erpCommon/security/Login.java
src/org/openbravo/erpCommon/security/Login.xml
web/skins/Default/Openbravo_ERP_250.css
--- a/src/index.jsp	Fri Jul 29 10:12:35 2011 +0200
+++ b/src/index.jsp	Fri Jul 29 09:52:21 2011 +0200
@@ -155,6 +155,17 @@
   // get rid of the loading stuff
   document.body.removeChild(document.getElementById('OBLoadingDiv'));
   OB.GlobalHiddenForm = document.forms.OBGlobalHiddenForm;
+<%
+  if (session.getAttribute("STARTUP-MESSAGE") != null) {
+    String text = (String) session.getAttribute("STARTUP-MESSAGE");
+    String title = (String) session.getAttribute("STARTUP-MESSAGE-TITLE");
+    session.removeAttribute("STARTUP-MESSAGE");
+    session.removeAttribute("STARTUP-MESSAGE-TITLE");
+%>
+  isc.say('<%=text%>', null, {title: '<%=title%>'});
+<%
+  }
+%>
 }
 </script>
 <script type="text/javascript" src="./web/org.openbravo.userinterface.smartclient/isomorphic/ISC_Combined.js"></script>
--- a/src/org/openbravo/erpCommon/security/Login.html	Fri Jul 29 10:12:35 2011 +0200
+++ b/src/org/openbravo/erpCommon/security/Login.html	Fri Jul 29 09:52:21 2011 +0200
@@ -255,9 +255,6 @@
     }
     topLogos.style.display = '';
     bottomLogos.style.display = '';
-
-    var msgContainer = document.getElementById('errorMsg');
-    msgContainer.innerHTML = '<span id="errorMsgTitle" class="Login_ErrorMsg_Title">xx</span><br><span id="errorMsgContent" class="Login_ErrorMsg_Content">xx</span>';
   }
 
   function maskLoginWindow(errorMsg) {
@@ -426,7 +423,9 @@
                   <input class="dojoValidateValid Login_TextBox" type="password" maxlength="40" name="password" id="password"/>
                 </dd>
               </dl>
-              <div id="errorMsg" class="LabelText Login_ErrorMsg_Container" style="display: none"><!-- xxChild tags developed in javascript --></div>
+              <div id="errorMsg" class="LabelText Login_ErrorMsg_Container" style="display:none;">
+                <span id="errorMsgTitle" class="Login_ErrorMsg_Title">xx</span><br><span id="errorMsgContent" class="Login_ErrorMsg_Content">xx</span>
+              </div>
             </div>
             <div class="Login_LogForm_Button_Container">
               <div class="Login_LogForm_Button">
@@ -452,6 +451,7 @@
                   </table>
                 </button>
               </div>
+              <div id="sign-in" style="margin-top:12px;">xxxSignIn</div>
             </div>
 
         </form>
--- a/src/org/openbravo/erpCommon/security/Login.java	Fri Jul 29 10:12:35 2011 +0200
+++ b/src/org/openbravo/erpCommon/security/Login.java	Fri Jul 29 09:52:21 2011 +0200
@@ -31,9 +31,11 @@
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.erpCommon.businessUtility.Preferences;
 import org.openbravo.erpCommon.obps.ActivationKey;
+import org.openbravo.erpCommon.utility.OBError;
 import org.openbravo.erpCommon.utility.OBVersion;
 import org.openbravo.erpCommon.utility.PropertyException;
 import org.openbravo.erpCommon.utility.Utility;
+import org.openbravo.model.ad.module.Module;
 import org.openbravo.model.ad.system.Client;
 import org.openbravo.model.ad.system.SystemInformation;
 import org.openbravo.xmlEngine.XmlDocument;
@@ -41,6 +43,8 @@
 public class Login extends HttpBaseServlet {
   private static final long serialVersionUID = 1L;
 
+  private static final String GOOGLE_INTEGRATION_MODULE_ID = "FF8080813129ADA401312CA1222A0005";
+
   public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException,
       ServletException {
     VariablesSecureApp vars = new VariablesSecureApp(request);
@@ -48,7 +52,6 @@
     if (vars.commandIn("LOGIN")) {
       log4j.debug("Command: Login");
       String strTheme = vars.getTheme();
-      vars.clearSession(false);
 
       OBContext.setAdminMode();
       try {
@@ -65,12 +68,13 @@
             .getLanguage().getLanguage());
 
         if (OBVersion.getInstance().is30()) {
-          printPageLogin30(response, strTheme, cacheMsg, validBrowserMsg, orHigherMsg,
+          printPageLogin30(vars, response, strTheme, cacheMsg, validBrowserMsg, orHigherMsg,
               recBrowserMsgTitle, recBrowserMsgText);
         } else {
           printPageLogin250(response, strTheme, cacheMsg, validBrowserMsg, orHigherMsg);
         }
       } finally {
+        vars.clearSession(false);
         OBContext.restorePreviousMode();
       }
 
@@ -226,17 +230,23 @@
   /**
    * Shows 3.0 login page
    */
-  private void printPageLogin30(HttpServletResponse response, String strTheme, String cacheMsg,
-      String validBrowserMsg, String orHigherMsg, String recBrowserMsgTitle,
-      String recBrowserMsgText) throws IOException, ServletException {
+  private void printPageLogin30(VariablesSecureApp vars, HttpServletResponse response,
+      String strTheme, String cacheMsg, String validBrowserMsg, String orHigherMsg,
+      String recBrowserMsgTitle, String recBrowserMsgText) throws IOException, ServletException {
 
     boolean showForgeLogo = true;
     boolean showITLogo = false;
     boolean showCompanyLogo = false;
+    boolean showGoogleIcon = false;
+
     String itLink = "";
     String companyLink = "";
     SystemInformation sysInfo = OBDal.getInstance().get(SystemInformation.class, "0");
 
+    Module module = OBDal.getInstance().get(Module.class, GOOGLE_INTEGRATION_MODULE_ID);
+
+    showGoogleIcon = (module != null);
+
     if (sysInfo == null) {
       log4j.error("System information not found");
     } else {
@@ -288,10 +298,28 @@
     xmlDocument.setParameter("recBrowserMsgTitle", recBrowserMsgTitleFinal.replaceAll("\\n", "\n"));
     xmlDocument.setParameter("recBrowserMsgText", recBrowserMsgTextFinal.replaceAll("\\n", "\n"));
 
+    if (showGoogleIcon) {
+
+      String authServlet = "../org.openbravo.service.integration.google/auth.html";
+      String link = "<p class=\"LabelText Login_LabelText\" style=\"line-height:24px;\">Sign in using:&nbsp; <a href=\""
+          + authServlet
+          + "\" title=\"Sign in using your Google Account\" target=\"_top\" "
+          + "><img style=\"vertical-align:middle;\" src=\"../web/images/google.png\" alt=\"Sign in using your Google Account\" width=\"24\" height=\"24\" border=\"0\"/></a></p>";
+
+      xmlDocument.setParameter("sign-in", link);
+    }
+
+    OBError error = (OBError) vars.getSessionObject("LoginErrorMsg");
+    if (error != null) {
+      vars.removeSessionValue("LoginErrorMsg");
+      xmlDocument.setParameter("errorMsgStyle", ""); // clear style
+      xmlDocument.setParameter("errorMsgTitle", error.getTitle());
+      xmlDocument.setParameter("errorMsgContent", error.getMessage());
+    }
+
     response.setContentType("text/html; charset=UTF-8");
     PrintWriter out = response.getWriter();
     out.println(xmlDocument.print());
     out.close();
   }
-
 }
--- a/src/org/openbravo/erpCommon/security/Login.xml	Fri Jul 29 10:12:35 2011 +0200
+++ b/src/org/openbravo/erpCommon/security/Login.xml	Fri Jul 29 09:52:21 2011 +0200
@@ -28,4 +28,8 @@
   <PARAMETER id="validBrowserMsgOrHigher" name="validBrowserMsgOrHigher" default=""/>
   <PARAMETER id="recBrowserMsgTitle" name="recBrowserMsgTitle" default=""/>
   <PARAMETER id="recBrowserMsgText" name="recBrowserMsgText" default=""/>
+  <PARAMETER id="errorMsg" name="errorMsgStyle" attribute="style" default="display:none;" />
+  <PARAMETER id="errorMsgTitle" name="errorMsgTitle" default="" />
+  <PARAMETER id="errorMsgContent" name="errorMsgContent" default="" />
+  <PARAMETER id="sign-in" name="sign-in" default=""/>
 </REPORT>
--- a/web/skins/Default/Openbravo_ERP_250.css	Fri Jul 29 10:12:35 2011 +0200
+++ b/web/skins/Default/Openbravo_ERP_250.css	Fri Jul 29 09:52:21 2011 +0200
@@ -4,14 +4,14 @@
  * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
  * Version 1.1  with a permitted attribution clause; you may not  use this
  * file except in compliance with the License. You  may  obtain  a copy of
- * the License at http://www.openbravo.com/legal/license.html 
+ * the License at http://www.openbravo.com/legal/license.html
  * Software distributed under the License  is  distributed  on  an "AS IS"
  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
  * License for the specific  language  governing  rights  and  limitations
- * under the License. 
- * The Original Code is Openbravo ERP. 
- * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2008-2010 Openbravo SLU 
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2008-2011 Openbravo SLU
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -5567,7 +5567,7 @@
 }
 
 .Login_LogForm_Button {
-  margin-top: 28px;
+  margin-top: 10px;
 }
 
 .Login_TopLogos_Container_Support_Forge,