From f73972ca422db2ba1f6df5ee0a71e0e04dfb1c3d Mon Sep 17 00:00:00 2001 From: Ty Date: Thu, 17 Oct 2024 08:53:24 -0400 Subject: [PATCH] Optionally suppress the email on handleVerification --- docker-compose.yml | 2 -- .../hatdex/hat/api/controllers/Authentication.scala | 12 ++++++++---- hat/conf/application.test.conf | 2 +- hat/conf/routes | 2 +- start.sh | 2 ++ 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 15e2118fa..a176ee04c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: "3" - services: db: image: postgres:13-alpine diff --git a/hat/app/org/hatdex/hat/api/controllers/Authentication.scala b/hat/app/org/hatdex/hat/api/controllers/Authentication.scala index 5fc5f46e7..7d2f0c979 100644 --- a/hat/app/org/hatdex/hat/api/controllers/Authentication.scala +++ b/hat/app/org/hatdex/hat/api/controllers/Authentication.scala @@ -507,10 +507,11 @@ class Authentication @Inject() ( Future.successful(response) } - def handleVerification(verificationToken: String): Action[ApiVerificationCompletionRequest] = + def handleVerification(verificationToken: String, sendEmailToUser: Option[Boolean]): Action[ApiVerificationCompletionRequest] = UserAwareAction.async(parsers.json[ApiVerificationCompletionRequest]) { implicit request => implicit val hatClaimComplete: ApiVerificationCompletionRequest = request.body implicit val language: Lang = Lang.defaultLang + implicit val sendEmail: Boolean = sendEmailToUser.getOrElse(true) tokenService.retrieve(verificationToken).flatMap { case Some(token) @@ -549,9 +550,11 @@ class Authentication @Inject() ( Done } - val fullyQualifiedHatAddress: String = - s"https://${hatClaimComplete.hatName}.${hatClaimComplete.hatCluster}" - mailer.emailVerified(token.email, fullyQualifiedHatAddress) + if (sendEmail) { + val fullyQualifiedHatAddress: String = + s"https://${hatClaimComplete.hatName}.${hatClaimComplete.hatCluster}" + mailer.emailVerified(token.email, fullyQualifiedHatAddress) + } result } // ???: this is fishy @@ -574,6 +577,7 @@ class Authentication @Inject() ( } } + private def updateHatMembership( claim: ApiVerificationCompletionRequest): Future[Done] = { val hattersClaimPayload = HattersClaimPayload(claim, isSandboxPda) diff --git a/hat/conf/application.test.conf b/hat/conf/application.test.conf index 92182b5f1..dba52bbd7 100644 --- a/hat/conf/application.test.conf +++ b/hat/conf/application.test.conf @@ -7,7 +7,7 @@ akka { } play.modules { - enabled += "play.api.cache.redis.RedisCacheModule" + disabled += "play.api.cache.redis.RedisCacheModule" disabled += "play.api.cache.ehcache.EhCacheModule" } diff --git a/hat/conf/routes b/hat/conf/routes index ce4aeae78..fba9814a1 100644 --- a/hat/conf/routes +++ b/hat/conf/routes @@ -25,7 +25,7 @@ POST /control/v2/auth/passwordReset org.hatdex.hat. POST /control/v2/auth/passwordreset/confirm/:token org.hatdex.hat.api.controllers.Authentication.handleResetPassword(token: String, sendEmailToUser: Option[Boolean]) POST /control/v2/auth/claim org.hatdex.hat.api.controllers.Authentication.handleVerificationRequest(lang: Option[String], sendEmailToUser: Option[Boolean]) POST /control/v2/auth/request-verification org.hatdex.hat.api.controllers.Authentication.handleVerificationRequest(lang: Option[String], sendEmailToUser: Option[Boolean]) -POST /control/v2/auth/claim/complete/:verificationToken org.hatdex.hat.api.controllers.Authentication.handleVerification(verificationToken: String) +POST /control/v2/auth/claim/complete/:verificationToken org.hatdex.hat.api.controllers.Authentication.handleVerification(verificationToken: String, sendEmailToUser: Option[Boolean]) # Metrics GET /metrics com.github.stijndehaes.playprometheusfilters.controllers.PrometheusController.getMetrics diff --git a/start.sh b/start.sh index 588c22b8f..de176d710 100644 --- a/start.sh +++ b/start.sh @@ -1,5 +1,7 @@ #!/bin/bash +# add send to user + export ADJUDICATOR_ADDRESS="https://contracts.hubat.net" export AWS_REGION="eu-west-1" export APPLICATION_CACHE_TTL="10 seconds"