fix mod search by email should normalize first
This commit is contained in:
parent
5fa8219135
commit
0def1c5e59
|
@ -15,7 +15,8 @@ final class Env(
|
|||
reportColl: Coll,
|
||||
lightUserApi: lila.user.LightUserApi,
|
||||
userSpy: String => Fu[UserSpy],
|
||||
securityApi: lila.security.Api) {
|
||||
securityApi: lila.security.Api,
|
||||
emailAddress: lila.security.EmailAddress) {
|
||||
|
||||
private object settings {
|
||||
val CollectionPlayerAssessment = config getString "collection.player_assessment"
|
||||
|
@ -61,7 +62,8 @@ final class Env(
|
|||
historyColl = db(CollectionGamingHistory))
|
||||
|
||||
lazy val search = new UserSearch(
|
||||
securityApi = securityApi)
|
||||
securityApi = securityApi,
|
||||
emailAddress = emailAddress)
|
||||
|
||||
private val neuralApi = new NeuralApi(
|
||||
endpoint = NeuralApiEndpoint,
|
||||
|
@ -96,5 +98,6 @@ object Env {
|
|||
reportColl = lila.report.Env.current.reportColl,
|
||||
userSpy = lila.security.Env.current.userSpy,
|
||||
lightUserApi = lila.user.Env.current.lightUserApi,
|
||||
securityApi = lila.security.Env.current.api)
|
||||
securityApi = lila.security.Env.current.api,
|
||||
emailAddress = lila.security.Env.current.emailAddress)
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package lila.mod
|
|||
|
||||
import lila.user.{ User, UserRepo }
|
||||
|
||||
final class UserSearch(securityApi: lila.security.Api) {
|
||||
final class UserSearch(
|
||||
securityApi: lila.security.Api,
|
||||
emailAddress: lila.security.EmailAddress) {
|
||||
|
||||
// http://stackoverflow.com/questions/106179/regular-expression-to-match-hostname-or-ip-address
|
||||
private val ipPattern = """^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$""".r.pattern
|
||||
|
@ -22,5 +24,7 @@ final class UserSearch(securityApi: lila.security.Api) {
|
|||
|
||||
private def searchUsername(username: String) = UserRepo named username map (_.toList)
|
||||
|
||||
private def searchEmail(email: String) = UserRepo byEmail email map (_.toList)
|
||||
private def searchEmail(email: String) = emailAddress.validate(email) ?? { fixed =>
|
||||
UserRepo byEmail fixed map (_.toList)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue