changeset 2969:16c71457ed43

Display error details to the user If an authentication fails the user should be informed about the reason. flys-client/trunk@4965 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Bjoern Ricks <bjoern.ricks@intevation.de>
date Fri, 13 Jul 2012 06:52:33 +0000
parents 3e0567e02577
children b89dd09b486c
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/server/LoginServlet.java flys-client/src/main/webapp/login.jsp
diffstat 3 files changed, 20 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Fri Jul 13 06:46:27 2012 +0000
+++ b/flys-client/ChangeLog	Fri Jul 13 06:52:33 2012 +0000
@@ -1,3 +1,9 @@
+2012-07-13	Björn Ricks	<bjoern.ricks@intevation.de>
+
+	* src/main/webapp/login.jsp,
+	  src/main/java/de/intevation/flys/client/server/LoginServlet.java:
+	  Display exception details to the user if an authentication fails.
+
 2012-07-13	Björn Ricks	<bjoern.ricks@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/server/auth/Authentication.java,
--- a/flys-client/src/main/java/de/intevation/flys/client/server/LoginServlet.java	Fri Jul 13 06:46:27 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/LoginServlet.java	Fri Jul 13 06:52:33 2012 +0000
@@ -23,6 +23,10 @@
         resp.sendRedirect("/login.jsp");
     }
 
+    private void redirectFailure(HttpServletResponse resp, Exception e) throws IOException {
+        resp.sendRedirect("/login.jsp?error=" + e.getMessage());
+    }
+
     private void redirectSuccess(HttpServletResponse resp, String uri) throws IOException {
         if (uri == null) {
             uri = "/FLYS.html";
@@ -65,8 +69,7 @@
             this.redirectSuccess(resp, uri);
         }
         catch(AuthenticationException e) {
-            //TODO User could not be authenticated
-            throw new ServletException(e);
+            this.redirectFailure(resp, e);
         }
     }
 
--- a/flys-client/src/main/webapp/login.jsp	Fri Jul 13 06:46:27 2012 +0000
+++ b/flys-client/src/main/webapp/login.jsp	Fri Jul 13 06:52:33 2012 +0000
@@ -8,6 +8,15 @@
     <body>
         <form method="POST" action="/flys/login" id="authentication">
             <h1>FLYS Anmeldung</h1>
+            <% String error = request.getParameter("error"); %>
+            <% if (error != null) { %>
+                <div class="error">
+                    <h2>Authentifizierung fehlgeschlagen</h2>
+                    <div class="details">
+                        <%= error %>
+                    </div>
+                </div>
+            <% } %>
             <div>Bitte geben Sie eine Benutzerkennung und ein Passwort ein.</div>
             <table>
                 <tr>

http://dive4elements.wald.intevation.org