Skip to content

Commit 8490954

Browse files
xingzhang-suseBinX-Suse
authored andcommitted
NVSHAS-10062: [Manager] manager not showing ERROR when failing to create admin password during 1st login
1 parent deca737 commit 8490954

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

admin/src/main/scala/com/neu/service/BaseService.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import org.apache.pekko.http.scaladsl.server.Directives
1313
import org.apache.pekko.http.scaladsl.server.StandardRoute
1414
import org.apache.pekko.http.scaladsl.unmarshalling.Unmarshaller
1515
import spray.json.*
16+
import com.neu.core.HttpResponseException
1617

1718
import java.io.PrintWriter
1819
import java.io.StringWriter
@@ -57,14 +58,14 @@ open class BaseService extends Directives with LazyLogging {
5758
}
5859
}
5960

60-
protected def onUnauthorized(e: Throwable): StandardRoute =
61-
if (e.getMessage.contains("\"code\":14")) {
62-
complete((StatusCodes.BadRequest, e.getMessage))
63-
} else if (e.getMessage.contains("\"code\":47")) {
61+
protected def onUnauthorized(e: HttpResponseException, res: String): StandardRoute =
62+
if (res.contains("\"code\":14")) {
63+
complete((StatusCodes.BadRequest, res))
64+
} else if (res.contains("\"code\":47")) {
6465
complete((StatusCodes.Unauthorized, blocked))
65-
} else if (e.getMessage.contains("\"code\":48")) {
66+
} else if (res.contains("\"code\":48")) {
6667
complete((StatusCodes.Unauthorized, passwordExpired))
67-
} else if (e.getMessage.contains("\"code\":50")) {
68+
} else if (res.contains("\"code\":50")) {
6869
complete(StatusCodes.Unauthorized, authSSODisabledError)
6970
} else {
7071
complete((StatusCodes.Unauthorized, authError))

admin/src/main/scala/com/neu/service/authentication/SuseAuthService.scala

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,17 @@ class SuseAuthService()(implicit
8181
logger.info("post path auth")
8282
processSuseLoginRequest(ip, userPwd, suseCookieValue)
8383
} catch {
84-
case NonFatal(e) =>
85-
logger.warn(e.getMessage)
86-
84+
case NonFatal(e: HttpResponseException) =>
85+
val response = Await.result(
86+
e.response.entity.toStrict(5.seconds).map(_.data.utf8String),
87+
RestClient.waitingLimit.seconds
88+
)
8789
if (
8890
e.getMessage
8991
.contains("Status: 400") || e.getMessage.contains("Status: 401") || e.getMessage
9092
.contains("Status: 403")
9193
) {
92-
onUnauthorized(e)
94+
onUnauthorized(e, response)
9395
} else if (e.getMessage.contains("Status: 410")) {
9496
complete((StatusCodes.Gone, "Please logout and then login from Rancher again!"))
9597
} else {
@@ -107,7 +109,7 @@ class SuseAuthService()(implicit
107109
"Status: 403"
108110
)
109111
) {
110-
onUnauthorized(e)
112+
onUnauthorized(e, response)
111113
} else if (e.getMessage.contains("Status: 410")) {
112114
complete(
113115
(StatusCodes.Gone, "Please logout and then login from Rancher again!")
@@ -120,7 +122,7 @@ class SuseAuthService()(implicit
120122
complete((StatusCodes.NetworkConnectTimeout, "Network connect timeout error"))
121123
}
122124
}
123-
case e: TimeoutException =>
125+
case e: TimeoutException =>
124126
logger.warn(e.getMessage)
125127

126128
complete((StatusCodes.NetworkConnectTimeout, "Network connect timeout error"))

admin/webapp/websrc/app/routes/pages/login/login.component.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -676,12 +676,9 @@ export class LoginComponent implements OnInit, OnDestroy {
676676
dialogRef.componentInstance.onClose();
677677
},
678678
({ error }) => {
679-
let resetError: ResetError = JSON.parse(
680-
error.split('Body:')[1].trim()
681-
);
682679
dialogRef.componentInstance.pwdProfile =
683-
resetError.password_profile_basic;
684-
dialogRef.componentInstance.resetError = resetError.message;
680+
error.password_profile_basic;
681+
dialogRef.componentInstance.resetError = error.message;
685682
}
686683
);
687684
});

0 commit comments

Comments
 (0)