Return only exact matches from InternalAccountQuery#byPreferredEmail

Doing an account query on the preferredemail field finds accounts with a
preferred email that matches the given email case insensitive or that
starts with that prefix (also case insensitive). However all callers are
only interested in exact matches. Instead of letting each caller filter
out non-exact matches do this filtering once in
InternalAccountQuery#byPreferredEmail.

Change-Id: If893d1bd8857fd69b3c2222ba104aa9ee212f936
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2017-08-18 09:10:01 +02:00
parent 916112ed91
commit 790250d0c7
3 changed files with 28 additions and 15 deletions

View File

@@ -223,8 +223,6 @@ class BecomeAnyAccountLoginServlet extends HttpServlet {
.get()
.byPreferredEmail(email)
.stream()
// the index query also matches prefixes, filter those out
.filter(a -> email.equalsIgnoreCase(a.getAccount().getPreferredEmail()))
.map(AccountState::getAccount)
.findFirst();
return match.isPresent() ? auth(match.get()) : null;