From a36ea3a223f114923bc8d85b0ebe17e2948decad Mon Sep 17 00:00:00 2001 From: Tristan Garwood Date: Mon, 20 Nov 2023 15:01:40 -0500 Subject: [PATCH] trying this instead --- .../firecloud/service/RegisterService.scala | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/main/scala/org/broadinstitute/dsde/firecloud/service/RegisterService.scala b/src/main/scala/org/broadinstitute/dsde/firecloud/service/RegisterService.scala index 754a191a0..2ee0af3dd 100644 --- a/src/main/scala/org/broadinstitute/dsde/firecloud/service/RegisterService.scala +++ b/src/main/scala/org/broadinstitute/dsde/firecloud/service/RegisterService.scala @@ -1,20 +1,18 @@ package org.broadinstitute.dsde.firecloud.service +import akka.http.scaladsl.model.StatusCodes import com.typesafe.scalalogging.LazyLogging +import org.broadinstitute.dsde.firecloud.FireCloudConfig.Sam import org.broadinstitute.dsde.firecloud.dataaccess._ import org.broadinstitute.dsde.firecloud.model.ModelJsonProtocol._ import org.broadinstitute.dsde.firecloud.model._ import org.broadinstitute.dsde.firecloud.service.PerRequest.{PerRequestMessage, RequestComplete} import org.broadinstitute.dsde.firecloud.{Application, FireCloudConfig, FireCloudExceptionWithErrorReport} -import org.broadinstitute.dsde.workbench.model.Notifications.{ActivationNotification, AzurePreviewActivationNotification, AzurePreviewActivationNotificationType, Notification, NotificationFormat} import org.broadinstitute.dsde.rawls.model.ErrorReport -import akka.http.scaladsl.model.StatusCodes -import org.broadinstitute.dsde.firecloud.FireCloudConfig.Sam +import org.broadinstitute.dsde.workbench.model.Notifications.{ActivationNotification, AzurePreviewActivationNotification, Notification, NotificationFormat} import org.broadinstitute.dsde.workbench.model.WorkbenchUserId -import scala.concurrent.duration.{Duration, DurationInt} -import scala.concurrent.{Await, ExecutionContext, Future} -import scala.language.postfixOps +import scala.concurrent.{ExecutionContext, Future} object RegisterService { val samTosTextUrl = s"${Sam.baseUrl}/tos/text" @@ -30,16 +28,17 @@ object RegisterService { class RegisterService(val rawlsDao: RawlsDAO, val samDao: SamDAO, val thurloeDao: ThurloeDAO, val googleServicesDAO: GoogleServicesDAO) (implicit protected val executionContext: ExecutionContext) extends LazyLogging { - def createUserWithProfile(userInfo: UserInfo, registerRequest: RegisterRequest, waitAtMostForSam: Duration = 10 seconds): Future[PerRequestMessage] = { - val registerResult: SamUserResponse = Await.result(registerUser(userInfo, registerRequest.acceptsTermsOfService), waitAtMostForSam) + def createUserWithProfile(userInfo: UserInfo, registerRequest: RegisterRequest): Future[PerRequestMessage] = for { - _ <- thurloeDao.saveProfile(userInfo, registerRequest.profile) - _ <- thurloeDao.saveKeyValues(userInfo, Map("isRegistrationComplete" -> Profile.currentVersion.toString)) + registerResult <- registerUser(userInfo, registerRequest.acceptsTermsOfService) + // We are using the equivalent value from sam registration to force the order of operations for the thurloe calls + registrationResultUserInfo = userInfo.copy(userEmail = registerResult.email.value) + _ <- thurloeDao.saveProfile(registrationResultUserInfo, registerRequest.profile) + _ <- thurloeDao.saveKeyValues(registrationResultUserInfo, Map("isRegistrationComplete" -> Profile.currentVersion.toString)) _ <- if (!registerResult.allowed) { - thurloeDao.saveKeyValues(userInfo, Map("email" -> userInfo.userEmail)) + thurloeDao.saveKeyValues(registrationResultUserInfo, Map("email" -> userInfo.userEmail)) } else Future.successful() } yield RequestComplete(StatusCodes.OK, registerResult) - } def createUpdateProfile(userInfo: UserInfo, basicProfile: BasicProfile): Future[PerRequestMessage] = { for {