def revokeAccount()

in app/controllers/RevokePermissions.scala [73:117]


  def revokeAccount(accountId: String) = authAction { implicit request =>
    val result = for {
      account <- janusData.accounts
        .find(accountId == _.authConfigKey)
        .toRight("Account not found")
      submission <- request.body.asFormUrlEncoded.toRight(
        "Could not parse submission"
      )
      confirmationKey <- submission
        .get("confirm")
        .flatMap(_.headOption)
        .toRight("Missing account confirmation")
      targetRoleArn = Config.roleArn(account.authConfigKey, configuration)
    } yield {
      if (Revocation.checkConfirmation(confirmationKey, account)) {
        Federation.disableFederation(
          account,
          Instant.now(),
          targetRoleArn,
          stsClient
        )
        logger.warn(
          s"Janus access revoked for $accountId by ${username(request.user)}"
        )
        Redirect(routes.RevokePermissions.revokeConfirmation(Some(accountId)))
      } else {
        logger.warn(
          s"Confirmation key $confirmationKey did not match for $accountId by ${username(request.user)}"
        )
        Redirect(routes.RevokePermissions.revokeRequest(accountId))
          .flashing(
            "confirmation-error" -> "Confirmation did not match the account."
          )
      }
    }
    result.fold(
      { errMsg =>
        logger.warn(
          s"$errMsg: denied REVOKE confirmation screen for $accountId by ${username(request.user)}"
        )
        BadRequest(views.html.error(errMsg, Some(request.user), janusData))
      },
      identity
    )
  }