[Yanel-dev] Patch for YanelServlet

basZero baszero at gmail.com
Wed Sep 7 10:22:54 CEST 2011


Hi Michael,

a very simple quick fix for the YanelServlet.

Use Case:
1) A user that has been logged in once, has an AutoLogin cookie
2) At some point in time, the user gets deleted in the system (for whatever
reason)
3) If the user visits the site again, the YanelServlet throws an
NullPointerException, because it can not login the user automatically
(setIdentity()), even though username in cookie matches the username stored
in the cookie.xml on server side.

The attached patch includes an IF statement, making sure that the user
really still exists.

Cheers
Balz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wyona.org/pipermail/yanel-development/attachments/20110907/f0719bfb/attachment.html>
-------------- next part --------------
Index: src/webapp/src/java/org/wyona/yanel/servlet/YanelServlet.java
===================================================================
--- src/webapp/src/java/org/wyona/yanel/servlet/YanelServlet.java	(revision 60488)
+++ src/webapp/src/java/org/wyona/yanel/servlet/YanelServlet.java	(working copy)
@@ -1124,7 +1124,9 @@
                     String username = AutoLogin.getUsername(request);
                     if (username != null) {
                         User user = realm.getIdentityManager().getUserManager().getUser(username);
-                        setIdentity(new Identity(user, user.getEmail()), request.getSession(), realm);
+                        if (user != null) {
+                            setIdentity(new Identity(user, user.getEmail()), request.getSession(), realm);
+                        }
                     } else {
                         log.error("Auto login successful, but no username available!");
                     }


More information about the Yanel-development mailing list