Skip to content

Commit d8cfa0b

Browse files
committed
add ExecutionContext as implicit argument #46
1 parent 47c6106 commit d8cfa0b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

play2-oauth2-provider/src/main/scala/scalaoauth2/provider/OAuth2Provider.scala

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ package scalaoauth2.provider
33
import play.api.libs.json._
44
import play.api.mvc._
55

6-
import scala.concurrent.ExecutionContext.Implicits.global
7-
import scala.concurrent.Future
6+
import scala.concurrent.{ExecutionContext, Future}
87
import scala.language.implicitConversions
98

109
/**
@@ -113,11 +112,13 @@ trait OAuth2Provider extends OAuth2BaseProvider {
113112
*
114113
* @param handler Implemented AuthorizationHandler for register access token to your system.
115114
* @param request Playframework is provided HTTP request interface.
115+
* @param ctx This context is used by TokenEndPoint.
116116
* @tparam A play.api.mvc.Request has type.
117+
* @tparam U set the type in AuthorizationHandler.
117118
* @return Request is successful then return JSON to client in OAuth 2.0 format.
118119
* Request is failed then return BadRequest or Unauthorized status to client with cause into the JSON.
119120
*/
120-
def issueAccessToken[A, U](handler: AuthorizationHandler[U])(implicit request: Request[A]): Future[Result] = {
121+
def issueAccessToken[A, U](handler: AuthorizationHandler[U])(implicit request: Request[A], ctx: ExecutionContext): Future[Result] = {
121122
tokenEndpoint.handleRequest(request, handler).map {
122123
case Left(e) if e.statusCode == 400 => BadRequest(responseOAuthErrorJson(e)).withHeaders(responseOAuthErrorHeader(e))
123124
case Left(e) if e.statusCode == 401 => Unauthorized(responseOAuthErrorJson(e)).withHeaders(responseOAuthErrorHeader(e))
@@ -131,11 +132,13 @@ trait OAuth2Provider extends OAuth2BaseProvider {
131132
* @param handler Implemented ProtectedResourceHandler for authenticate to your system.
132133
* @param callback Callback is called when authentication is successful.
133134
* @param request Playframework is provided HTTP request interface.
135+
* @param ctx This contxt is used by ProtectedResource.
134136
* @tparam A play.api.mvc.Request has type.
137+
* @tparam U set the type in AuthorizationHandler.
135138
* @return Authentication is successful then the response use your API result.
136139
* Authentication is failed then return BadRequest or Unauthorized status to client with cause into the JSON.
137140
*/
138-
def authorize[A, U](handler: ProtectedResourceHandler[U])(callback: AuthInfo[U] => Future[Result])(implicit request: Request[A]): Future[Result] = {
141+
def authorize[A, U](handler: ProtectedResourceHandler[U])(callback: AuthInfo[U] => Future[Result])(implicit request: Request[A], ctx: ExecutionContext): Future[Result] = {
139142
protectedResource.handleRequest(request, handler).flatMap {
140143
case Left(e) if e.statusCode == 400 => Future.successful(BadRequest.withHeaders(responseOAuthErrorHeader(e)))
141144
case Left(e) if e.statusCode == 401 => Future.successful(Unauthorized.withHeaders(responseOAuthErrorHeader(e)))

0 commit comments

Comments
 (0)