Skip to content

Commit

Permalink
Implementation of refreshToken refs #128
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayybeeshafi committed Mar 13, 2019
1 parent dfe843c commit f7e7404
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions app/controllers/InstanceRegistryController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class InstanceRegistryController @Inject()(implicit system: ActorSystem, mat: Ma
//val token = request.headers.get(HeaderNames.AUTHORIZATION)



/** This method maps list of instances with specific componentType.
*
* @param componentType
Expand Down Expand Up @@ -149,7 +148,8 @@ class InstanceRegistryController @Inject()(implicit system: ActorSystem, mat: Ma
}

/**
* This method is called to assign a new instance to the instance with specified ID.
* This method is called to assign a new instance to the instance with specified ID.
*
* @param from
* @param to
* @return
Expand Down Expand Up @@ -226,36 +226,38 @@ class InstanceRegistryController @Inject()(implicit system: ActorSystem, mat: Ma
new Status(response.status)
}
}
}.getOrElse{ Future(BadRequest("Invalid body"))}
}.getOrElse {
Future(BadRequest("Invalid body"))
}

}
}

/**
* This function is used to add a label to specific instance.
*
* @param instanceID ID of the instance on which label is to be added
* @param label
* @return
*/

def labelInstance(instanceID: String, label: String): Action[AnyContent] = authAction.async
{
def labelInstance(instanceID: String, label: String): Action[AnyContent] = authAction.async {
request =>
ws.url(instanceRegistryUri + "/instances/" + instanceID + "/label")
.withHttpHeaders(("Authorization", s"Bearer ${AuthProvider.generateJwt()}"))
.post(Json.obj("Label" -> label))
.map { response =>
response.status match {
// scalastyle:off magic.number
case 202 =>
// scalastyle:on magic.number
Ok(response.body)
case x: Any =>
new Status(x)
}
}(myExecutionContext)
ws.url(instanceRegistryUri + "/instances/" + instanceID + "/label")
.withHttpHeaders(("Authorization", s"Bearer ${AuthProvider.generateJwt()}"))
.post(Json.obj("Label" -> label))
.map { response =>
response.status match {
// scalastyle:off magic.number
case 202 =>
// scalastyle:on magic.number
Ok(response.body)
case x: Any =>
new Status(x)
}
}(myExecutionContext)
}

def refreshToken(token: String): Action[AnyContent] = authAction.async
def refreshToken(): Action[AnyContent] = authAction.async
{
request =>
ws.url(instanceRegistryUri + "/users" + "/refreshToken")
Expand All @@ -270,4 +272,4 @@ class InstanceRegistryController @Inject()(implicit system: ActorSystem, mat: Ma
}
}(myExecutionContext)
}
}
}

0 comments on commit f7e7404

Please sign in to comment.