Skip to content

Commit 8dfdae9

Browse files
refactor(directlogin): remove dead Lift dlServe block + vestigial RestHelper
The bare `POST /my/logins/direct` route has been served by `code.api.DirectLoginRoutes` (wired into `Http4sApp.baseServices`) since `LiftRules.statelessDispatch.append(DirectLogin)` was removed from `Boot.scala`. That left the `dlServe` self-registration block inside `DirectLogin` as dead code — `super.serve(...)` only does anything when the object is registered with `LiftRules`, which it no longer is. Removed: - the `dlServe` helper (its only job was wrapping a handler in `RestHelper.serve`), - the `dlServe { case Req("my" :: "logins" :: "direct" :: Nil, _, PostRequest) }` registration block, - `extends RestHelper` (now only `MdcLoggable`) — nothing outside the dead block used a RestHelper member; there were no `.extract`/`Formats` call sites, so no local `Formats` replacement was needed (unlike the OAuth2/GatewayLogin/DAuth de-RestHelper cleanups), - the now-unused `RestHelper` and `NewStyle.HttpCode` imports. Kept (still have live callers): `createTokenCommonPart`, `getAllParameters`, `validator`, `validatorFuture`, `validatorFutureWithParams`, `getUserFromDirectLoginHeaderFuture`, `getUser`, `getConsumer`, `grantEntitlementsToUseDynamicEndpointsInSpacesInDirectLogin`, and the token/consumer/user lookup helpers used by the auth flows. No behavioural change: the removed block was never reachable after the Boot dispatch removal. obp-api compiles; no test referenced the removed members.
1 parent c728ba7 commit 8dfdae9

1 file changed

Lines changed: 1 addition & 34 deletions

File tree

obp-api/src/main/scala/code/api/directlogin.scala

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import java.util.Date
3030

3131
import code.api.util.APIUtil._
3232
import code.api.util.ErrorMessages.{InvalidDirectLoginParameters, attemptedToOpenAnEmptyBox}
33-
import code.api.util.NewStyle.HttpCode
3433
import code.api.util._
3534
import code.consumer.Consumers._
3635
import code.model.dataAccess.AuthUser
@@ -44,7 +43,6 @@ import com.openbankproject.commons.ExecutionContext.Implicits.global
4443
import com.openbankproject.commons.model.User
4544
import net.liftweb.common._
4645
import net.liftweb.http._
47-
import net.liftweb.http.rest.RestHelper
4846
import net.liftweb.mapper.{By, By_>, Descending, OrderBy}
4947
import net.liftweb.util.Helpers
5048
import net.liftweb.util.Helpers.tryo
@@ -79,39 +77,8 @@ object JSONFactory {
7977
}
8078
}
8179

82-
object DirectLogin extends RestHelper with MdcLoggable {
80+
object DirectLogin extends MdcLoggable {
8381

84-
// Our version of serve
85-
def dlServe(handler : PartialFunction[Req, JsonResponse]) : Unit = {
86-
val obpHandler : PartialFunction[Req, () => Box[LiftResponse]] = {
87-
new PartialFunction[Req, () => Box[LiftResponse]] {
88-
def apply(r : Req) = {
89-
handler(r)
90-
}
91-
def isDefinedAt(r : Req) = handler.isDefinedAt(r)
92-
}
93-
}
94-
super.serve(obpHandler)
95-
}
96-
97-
dlServe
98-
{
99-
//Handling get request for a token
100-
case Req("my" :: "logins" :: "direct" :: Nil,_ , PostRequest) => {
101-
for{
102-
(httpCode: Int, message: String, userId:Long) <- createTokenFuture(getAllParameters)
103-
_ <- Future{grantEntitlementsToUseDynamicEndpointsInSpacesInDirectLogin(userId)}
104-
} yield {
105-
if (httpCode == 200) {
106-
(JSONFactory.createTokenJSON(message), HttpCode.`201`(CallContext()))
107-
} else {
108-
unboxFullOrFail(Empty, None, message, httpCode)
109-
}
110-
}
111-
}
112-
}
113-
114-
11582
def grantEntitlementsToUseDynamicEndpointsInSpacesInDirectLogin(userId:Long) = {
11683
try {
11784
val resourceUser = UserX.findByResourceUserId(userId).openOrThrowException(s"$InvalidDirectLoginParameters can not find the resourceUser!")

0 commit comments

Comments
 (0)