Display the Login page instead of empty dialog

During development it is common to erase the local development datastore
and start over. However if the browser in use still had a valid
authentication cookie (very common), a blank dialog would be displayed
because the cookie resolved to a non-existent account. This change
results instead with either the login page, or Google authentication
being invoked (depending on configuration). Note: This code should *not*
get triggered in production.

Change-Id: Iafbc7c774c392d99073342c49108dc6774e715a0
parent dfe67162
...@@ -145,7 +145,16 @@ public class OdeAuthFilter implements Filter { ...@@ -145,7 +145,16 @@ public class OdeAuthFilter implements Filter {
// find the UserData object. // find the UserData object.
String lemail = localUser.getUserEmail(); String lemail = localUser.getUserEmail();
if (lemail.equals("")) { if (lemail.equals("")) {
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); // We send a SC_PRECONDITION_FAILED which will cause the login page to
// be displayed (or the use of Google Authentication if that is the only
// mechanism enabled). This should *not* happen in production. However
// it happens all the time in development when people do an "ant clean"
// followed by an "ant". This results in their development datastore being
// erased. But their browser still contains a valid authentication cookie,
// but the userId no longer exists. It is then automatically created
// in code called before here, but the e-mail address is not set. So
// we error out here.
response.setStatus(HttpServletResponse.SC_PRECONDITION_FAILED);
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment