Skip to content

Commit beecd39

Browse files
committed
Simplify CallContextBasicAuthenticator.handleAuthentication()
1 parent 1c9abfc commit beecd39

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

oauth2-server-core/src/main/java/nl/myndocs/oauth2/request/auth/CallContextBasicAuthenticator.kt

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,10 @@ import nl.myndocs.oauth2.request.CallContext
44
import nl.myndocs.oauth2.router.RedirectRouter
55

66
object CallContextBasicAuthenticator {
7-
fun handleAuthentication(callContext: CallContext, callRouter: RedirectRouter) {
8-
val basicAuthenticator = BasicAuthenticator(callContext)
9-
if (basicAuthenticator.extractCredentials() == null) {
10-
basicAuthenticator.openAuthenticationDialog()
11-
} else {
12-
callRouter.route(callContext, basicAuthenticator.extractCredentials())
13-
.also {
14-
if (!it.successfulLogin) {
15-
basicAuthenticator.openAuthenticationDialog()
16-
}
17-
}
7+
fun handleAuthentication(context: CallContext, router: RedirectRouter) = with(BasicAuthenticator(context)) {
8+
router.route(context, this.extractCredentials()).also { response ->
9+
if (!response.successfulLogin)
10+
openAuthenticationDialog()
1811
}
1912
}
2013
}

0 commit comments

Comments
 (0)