Skip to content

Commit 9ee8664

Browse files
authored
Merge pull request #2716 from hongwei1/obp-develop
feature/added provider to verifyUserCredentials endpoint
2 parents ccdc11f + 54b9e83 commit 9ee8664

File tree

4 files changed

+5
-30
lines changed

4 files changed

+5
-30
lines changed

flushall_fast_build_and_run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ if [ $BUILD_EXIT_CODE -ne 0 ] && [ -z "$DO_CLEAN" ]; then
207207

208208
# Check if error is related to missing classes/packages (common cache issue)
209209
if grep -q "is not a member of package\|cannot find symbol\|not found: type\|not found: value" fast_build.log; then
210-
echo "🔄 Detected incremental compilation cache issue. Retrying with clean build..."
210+
echo "Detected incremental compilation cache issue. Retrying with clean build..."
211211
echo ""
212212

213213
# Backup the failed incremental build log
@@ -284,7 +284,7 @@ fi
284284
# Final error check
285285
if [ $BUILD_EXIT_CODE -ne 0 ]; then
286286
echo ""
287-
echo "Build failed! Please check fast_build.log for details."
287+
echo "Build failed! Please check fast_build.log for details."
288288
echo "Last 30 lines of build log:"
289289
tail -30 fast_build.log
290290
exit 1

obp-api/src/main/scala/code/api/v6_0_0/APIMethods600.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8719,7 +8719,7 @@ trait APIMethods600 {
87198719
}
87208720
// Validate credentials using the existing AuthUser mechanism
87218721
resourceUserIdBox = //we first try to get the userId from local, if not find, we try to get it from external
8722-
code.model.dataAccess.AuthUser.getResourceUserId(postedData.username, postedData.password)
8722+
code.model.dataAccess.AuthUser.getResourceUserId(postedData.username, postedData.password, postedData.provider)
87238723
.or(code.model.dataAccess.AuthUser.externalUserHelper(postedData.username, postedData.password).map(_.user.get))
87248724
// Check if account is locked
87258725
_ <- Helper.booleanToFuture(UsernameHasBeenLocked, 401, callContext) {

obp-api/src/main/scala/code/model/dataAccess/AuthUser.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -783,8 +783,8 @@ import net.liftweb.util.Helpers._
783783

784784

785785

786-
def getResourceUserId(username: String, password: String): Box[Long] = {
787-
findAuthUserByUsernameLocallyLegacy(username) match {
786+
def getResourceUserId(username: String, password: String, provider: String = Constant.localIdentityProvider): Box[Long] = {
787+
findAuthUserByUsernameAndProvider(username, provider) match {
788788
// We have a user from the local provider.
789789
case Full(user) if (user.getProvider() == Constant.localIdentityProvider) =>
790790
if (

obp-api/src/test/scala/code/api/v6_0_0/VerifyUserCredentialsTest.scala

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -178,31 +178,6 @@ class VerifyUserCredentialsTest extends V600ServerSetup with DefaultUsers {
178178
response.body.extract[ErrorMessage].message should include("OBP-20004")
179179
}
180180

181-
scenario("Successfully verify with empty provider (provider check is optional)", ApiEndpoint, VersionOfApi) {
182-
// Add the required entitlement
183-
val addedEntitlement = Entitlement.entitlement.vend.addEntitlement("", resourceUser1.userId, CanVerifyUserCredentials.toString)
184-
185-
When("We verify valid credentials with empty provider")
186-
val postJson = Map(
187-
"username" -> testUsername,
188-
"password" -> testPassword,
189-
"provider" -> ""
190-
)
191-
val request = (v6_0_0_Request / "users" / "verify-credentials").POST <@ (user1)
192-
val response = try {
193-
makePostRequest(request, write(postJson))
194-
} finally {
195-
// Clean up entitlement
196-
Entitlement.entitlement.vend.deleteEntitlement(addedEntitlement)
197-
}
198-
199-
Then("We should get a 200 (provider check is skipped when empty)")
200-
response.code should equal(200)
201-
202-
And("The response should contain user details")
203-
(response.body \ "username").extract[String] should equal(testUsername)
204-
}
205-
206181
scenario("Fail to verify with mismatched provider", ApiEndpoint, VersionOfApi) {
207182
// Add the required entitlement
208183
val addedEntitlement = Entitlement.entitlement.vend.addEntitlement("", resourceUser1.userId, CanVerifyUserCredentials.toString)

0 commit comments

Comments
 (0)