Guest User

Untitled

a guest
Jun 17th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. def confirmCode(
  2. userModel: UserModel,
  3. confirmationCodeType: ConfirmationCodeType,
  4. confirmationCode: String,
  5. newPhone: String
  6. ): DBIO[Either[Throwable, UpdateUserResult]] = {
  7. (for {
  8. code <- findActiveCode(confirmationCode, confirmationCodeType) eitherT
  9. _ <- confirmCodeByIdAndBindUserToIt(code.id, userId, now) eitherT
  10. _ <- updateUnconfirmedPhoneOrUserPhone(confirmationCodeType, userModel, newPhone) eitherT
  11. _ <- deactivateCodesByUser(userModel, confirmationCodeType) eitherT
  12. newCode <- autoCreateNewPhoneConfirmationCodeIfOldPhoneConfirmed(
  13. confirmationCodeType,
  14. userModel,
  15. newPhone) eitherT
  16. userUpdated <- findUserById(userModel.id) eitherT
  17. } yield UpdateUserResult(newPhoneCodeModel.confirmationCodeModel, Some(userUpdated.toAggregate))
  18. ).value
  19. }
Add Comment
Please, Sign In to add comment