修正官方源码中文登录界面密码出错空白页面

FsTy 提交于 周一, 01/21/2019 - 11:05

当选择语言为中文时,当登录用户账号密码不符时,跳转到http://*******/login页面,无任何内容显示。

语言为英文时,出错信息正常:

 

需要修改源码2个文件:

1.appinventor-sources\appinventor\appengine\war\login.jsp

<center><p><a href="/login/sendlink"  style="text-decoration:none;">${passwordclickhereLabel}</a></p></center>

修改为:

<center><p><a href="/login/sendlink?locale=<%= locale %>"  style="text-decoration:none;">${passwordclickhereLabel}</a></p></center>

2.appinventor-sources\appinventor\appengine\src\com\google\appinventor\server\LoginServlet.java

1.修改调用 fail(),大概有11处。

 fail(req, resp, ************);

修改为:

 fail(req, resp, locale,**********);

 2.修改 fail()函数,1处

private void fail(HttpServletRequest req, HttpServletResponse resp, String error) throws IOException {
    resp.sendRedirect("/login/?error=" + sanitizer.sanitize(error));
    return;
  }

修改为:

 private void fail(HttpServletRequest req, HttpServletResponse resp,String locale, String error) throws IOException {
    resp.sendRedirect("/login/?locale="+ locale +"&error=" + URLEncoder.encode(sanitizer.sanitize(error)));
    return;
  }

3.修改sendlink页面

 } else if (page.equals("sendlink")) {
      out = setCookieOutput(userInfo, resp);
      out.println("<head><title>" + bundle.getString("requestreset") + "</title></head>\n");
      out.println("<body>\n");
      out.println("<h1>" + bundle.getString("requestlink") + "</h1>\n");
      out.println("<p>" + bundle.getString("requestinstructions") + "</p>\n");
      out.println("<form method=POST action=\"" + req.getRequestURI() + "\">\n");
      out.println(bundle.getString("enteremailaddress") + ":&nbsp;<input type=text name=email value=\"\" size=\"35\"><br />\n");
      out.println("<p></p>");
      out.println("<input type=submit value=\"" + bundle.getString("sendlink") + "\" style=\"font-size: 300%;\">\n");
      out.println("</form>\n");
      return;
    }

替换为:

  } else if (page.equals("sendlink")) {
      out = setCookieOutput(userInfo, resp);
      out.println("<head><title>" + bundle.getString("requestreset") + "</title></head>\n");
      out.println("<body>\n");
      out.println("<h1>" + bundle.getString("requestlink") + "</h1>\n");
      out.println("<p>" + bundle.getString("requestinstructions") + "</p>\n");
      out.println("<form method=POST action=\"" + req.getRequestURI() +  "\">\n");
      out.println(bundle.getString("enteremailaddress") + ":&nbsp;<input type=text name=email value=\"\" size=\"35\"><br />\n");
      out.println("<p><input type=hidden name=locale value=\""+ locale + "\"></p>");
      out.println("<input type=submit value=\"" + bundle.getString("sendlink") + "\" style=\"font-size: 300%;\">\n");
      out.println("</form>\n");
      return;
    }

4.linksent加上语言

resp.sendRedirect("/login/linksent/");

替换为:

resp.sendRedirect("/login/linksent/?locale=" + locale);