Skip to content

Commit

Permalink
trying this instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghost-in-a-Jar committed Nov 20, 2023
1 parent edcd0d6 commit 0943f36
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ import akka.http.scaladsl.model.StatusCodes
import org.broadinstitute.dsde.firecloud.FireCloudConfig.Sam
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"
Expand All @@ -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 {
Expand Down

0 comments on commit 0943f36

Please sign in to comment.