let mods search users by previous email - requires new mongodb index

This commit is contained in:
Thibault Duplessis 2017-04-14 12:38:31 +02:00
parent 0430859e01
commit 251b392233
2 changed files with 2 additions and 1 deletions

View file

@ -20,6 +20,6 @@ final class UserSearch(
private def searchUsername(username: String) = UserRepo named username map (_.toList)
private def searchEmail(email: EmailAddress) = emailValidator.validate(email) ?? { fixed =>
UserRepo byEmail fixed map (_.toList)
UserRepo.byEmail(fixed) orElse UserRepo.byPrevEmail(fixed) map (_.toList)
}
}

View file

@ -35,6 +35,7 @@ object UserRepo {
def byIdsSecondary(ids: Iterable[ID]): Fu[List[User]] = coll.byIds[User](ids, ReadPreference.secondaryPreferred)
def byEmail(email: EmailAddress): Fu[Option[User]] = coll.uno[User]($doc(F.email -> email))
def byPrevEmail(email: EmailAddress): Fu[Option[User]] = coll.uno[User]($doc(F.prevEmail -> email))
def idByEmail(email: EmailAddress): Fu[Option[String]] =
coll.primitiveOne[String]($doc(F.email -> email), "_id")