Skip to content

Commit

Permalink
Merge pull request #694 from dataswift/suppress-emails-for-password-r…
Browse files Browse the repository at this point in the history
…eset

Optionally suppress the email on handleVerification
  • Loading branch information
mudspot authored Oct 17, 2024
2 parents ed490da + f73972c commit 7cee459
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3"

services:
db:
image: postgres:13-alpine
Expand Down
12 changes: 8 additions & 4 deletions hat/app/org/hatdex/hat/api/controllers/Authentication.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -574,6 +577,7 @@ class Authentication @Inject() (
}
}


private def updateHatMembership(
claim: ApiVerificationCompletionRequest): Future[Done] = {
val hattersClaimPayload = HattersClaimPayload(claim, isSandboxPda)
Expand Down
2 changes: 1 addition & 1 deletion hat/conf/application.test.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down
2 changes: 1 addition & 1 deletion hat/conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 7cee459

Please sign in to comment.