put null check into interceptor, addresses #183

pull/210/head
Justin Richer 2012-08-27 11:55:06 -04:00
parent 8361f74932
commit 259e84c871
1 changed files with 12 additions and 10 deletions

View File

@ -26,10 +26,11 @@ public class UserInfoInterceptor extends HandlerInterceptorAdapter {
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
// get our principal
if (modelAndView != null) { // skip checking at all if we have no model and view to hand the user to
// get our principal from the security context
Principal p = request.getUserPrincipal();
if (p != null && p.getName() != null) {
if (p != null && p.getName() != null) { // don't bother checking if we don't have a principal
// try to look up a user based on it
UserInfo user = userInfoRepository.getByUserId(p.getName());
@ -39,6 +40,7 @@ public class UserInfoInterceptor extends HandlerInterceptorAdapter {
modelAndView.addObject("userInfo", user);
}
}
}
}