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..161b42953 100644 --- a/src/main/scala/org/broadinstitute/dsde/firecloud/service/RegisterService.scala +++ b/src/main/scala/org/broadinstitute/dsde/firecloud/service/RegisterService.scala @@ -30,16 +30,16 @@ 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) + 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 {