Skip to content

Commit

Permalink
Use challenges for Yandex captcha
Browse files Browse the repository at this point in the history
  • Loading branch information
Karasiq committed Oct 26, 2020
1 parent 0ecb393 commit b0c5d7f
Showing 1 changed file with 7 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.karasiq.shadowcloud.storage.yandex

import java.awt.Desktop
import java.net.URI

import akka.Done
import akka.actor.{ActorContext, ActorRef}
import com.karasiq.shadowcloud.ShadowCloud
Expand All @@ -20,22 +17,15 @@ import scala.util.Try
class YandexStoragePlugin extends StoragePlugin {
override def createStorage(storageId: StorageId, props: StorageProps)(implicit context: ActorContext): ActorRef = {
import context.{dispatcher, system}
val sc = ShadowCloud()
val sc = ShadowCloud()
val api = new YandexWebApi(solveCaptcha = { imageUrl
Future {
sc.ui.showNotification(s"Yandex captcha required for $storageId: $imageUrl")
if (Desktop.isDesktopSupported) Desktop.getDesktop.browse(new URI(imageUrl))
sc.ui.askPassword("Yandex captcha")
}(sc.ui.executionContext)
sc.challenges
.create(s"Yandex captcha ($storageId)", s"""<img src="$imageUrl"/>""")
.map(_.utf8String)
}, passChallenge = { url
Future {
if (Desktop.isDesktopSupported) Desktop.getDesktop.browse(new URI(url))
sc.ui.showNotification(
s"Yandex verification required for $storageId: $url\n" +
"Please complete the verification and then press OK"
)
Done
}(sc.ui.executionContext)
sc.challenges
.create(s"Yandex verification ($storageId)", s"""<a href="$url">Please complete the verification</a>""")
.map(_ Done)
})

implicit val session: YandexSession = {
Expand Down

0 comments on commit b0c5d7f

Please sign in to comment.