Commit e13e9805 authored by Alinga Yeung's avatar Alinga Yeung
Browse files

Story 1869. Added code to return a 409 when more than one user is match an email address.

parent f5e30ec2
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -576,6 +576,19 @@ public class LdapUserDAO<T extends Principal> extends LdapDAO

            searchResult = getReadOnlyConnection().searchForEntry(searchRequest);
        }
        catch (LDAPSearchException e)
        {
            if (e.getResultCode() == ResultCode.SIZE_LIMIT_EXCEEDED)
            {
                String msg = "More than one User with email address " + emailAddress + " found";
                logger.debug(msg);
                throw new UserNotFoundException(msg);
            }
            else
            {
                LdapDAO.checkLdapResult(e.getResultCode());
            }
        }
        catch (LDAPException e)
        {
            LdapDAO.checkLdapResult(e.getResultCode());
@@ -591,6 +604,19 @@ public class LdapUserDAO<T extends Principal> extends LdapDAO
            {
                searchResult = getReadOnlyConnection().searchForEntry(searchRequest);
            }
            catch (LDAPSearchException e)
            {
                if (e.getResultCode() == ResultCode.SIZE_LIMIT_EXCEEDED)
                {
                    String msg = "More than one User with email address " + emailAddress + " found";
                    logger.debug(msg);
                    throw new UserNotFoundException(msg);
                }
                else
                {
                    LdapDAO.checkLdapResult(e.getResultCode());
                }
            }
            catch (LDAPException e)
            {
                LdapDAO.checkLdapResult(e.getResultCode());
+8 −1
Original line number Diff line number Diff line
@@ -187,9 +187,16 @@ public class ResetPasswordServlet extends HttpServlet
                log.debug(msg, e);
                logInfo.setMessage(msg);
                if (e instanceof UserNotFoundException)
                {            
                    if (e.getMessage().contains("More than one user"))
                    {
                        response.setStatus(HttpServletResponse.SC_CONFLICT);
                    }
                    else
                    {
                        response.setStatus(HttpServletResponse.SC_NOT_FOUND);
                    }
                }
                else
                {
                    response.setStatus(HttpServletResponse.SC_BAD_REQUEST);