@@ -2,7 +2,8 @@ package lib.actions
22
33import com .madgag .github .Implicits ._
44import com .madgag .github .{PullRequestId , RepoId }
5- import com .madgag .playgithub .auth .GHRequest
5+ import com .madgag .playgithub .auth .AuthenticatedSessions .AccessToken
6+ import com .madgag .playgithub .auth .{Client , GHRequest }
67import controllers .Application ._
78import controllers .Auth
89import lib ._
@@ -15,26 +16,30 @@ import play.api.mvc._
1516import scala .concurrent .ExecutionContext .Implicits .global
1617import scala .concurrent .Future
1718import scala .util .{Failure , Success , Try }
19+ import scalax .file .ImplicitConversions ._
1820
1921
2022object Actions {
2123 private val authScopes = Seq (" user:email" )
2224
23- val GitHubAuthenticatedAction = com.madgag.playgithub.auth.Actions .githubAction(authScopes)(Auth .authClient)
25+ implicit val authClient : Client = Auth .authClient
26+
27+ implicit val provider = AccessToken .FromSession
28+
29+ val GitHubAuthenticatedAction = com.madgag.playgithub.auth.Actions .gitHubAction(authScopes, Bot .workingDir.toPath)
2430
2531 def githubRepoAction (repoId : RepoId ) = GitHubAuthenticatedAction andThen new ActionRefiner [GHRequest , GHRepoRequest ] {
2632 override protected def refine [A ](request : GHRequest [A ]): Future [Either [Result , GHRepoRequest [A ]]] = Future {
2733 Either .cond(Project .byRepoId.contains(repoId), {
28- val gitHub = request.gitHub
2934 val repo = Bot .conn().getRepository(repoId.fullName)
30- new GHRepoRequest (gitHub , repo, request)}, Forbidden (" Not a supported repo" ))
35+ new GHRepoRequest (request.gitHubCredentials , repo, request)}, Forbidden (" Not a supported repo" ))
3136 }
3237 }
3338
3439 def githubPRAction (prId : PullRequestId ) = githubRepoAction(prId.repo) andThen new ActionRefiner [GHRepoRequest , GHPRRequest ] {
3540 override protected def refine [A ](request : GHRepoRequest [A ]): Future [Either [Result , GHPRRequest [A ]]] = Future {
3641 Try (request.repo.getPullRequest(prId.num)) match {
37- case Success (pr) => Right (new GHPRRequest [A ](request.gitHub , pr, request))
42+ case Success (pr) => Right (new GHPRRequest [A ](request.gitHubCredentials , pr, request))
3843 case Failure (e) => Left (NotFound (s " ${request.repo.getFullName} doesn't seem to have PR # ${prId.num}" ))
3944 }
4045 }
0 commit comments