From 21c29469bca31eb055457bb8659251d30f4f16a6 Mon Sep 17 00:00:00 2001 From: Tim Lai Date: Wed, 10 Mar 2021 15:53:14 -0800 Subject: [PATCH] refactor(auth): rename auth flow constants to be more descriptive (#7061) --- src/core/components/auth/oauth2.jsx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/core/components/auth/oauth2.jsx b/src/core/components/auth/oauth2.jsx index 6c9cfde91e3..7fec252f5a7 100644 --- a/src/core/components/auth/oauth2.jsx +++ b/src/core/components/auth/oauth2.jsx @@ -125,10 +125,10 @@ export default class Oauth2 extends React.Component { let oidcUrl = isOAS3() ? schema.get("openIdConnectUrl") : null // Auth type consts - const IMPLICIT = "implicit" - const PASSWORD = "password" - const ACCESS_CODE = isOAS3() ? (oidcUrl ? "authorization_code" : "authorizationCode") : "accessCode" - const APPLICATION = isOAS3() ? (oidcUrl ? "client_credentials" : "clientCredentials") : "application" + const AUTH_FLOW_IMPLICIT = "implicit" + const AUTH_FLOW_PASSWORD = "password" + const AUTH_FLOW_ACCESS_CODE = isOAS3() ? (oidcUrl ? "authorization_code" : "authorizationCode") : "accessCode" + const AUTH_FLOW_APPLICATION = isOAS3() ? (oidcUrl ? "client_credentials" : "clientCredentials") : "application" let flow = schema.get("flow") let scopes = schema.get("allowedScopes") || schema.get("scopes") @@ -147,12 +147,12 @@ export default class Oauth2 extends React.Component { { isAuthorized &&
Authorized
} { oidcUrl &&

OpenID Connect URL: { oidcUrl }

} - { ( flow === IMPLICIT || flow === ACCESS_CODE ) &&

Authorization URL: { schema.get("authorizationUrl") }

} - { ( flow === PASSWORD || flow === ACCESS_CODE || flow === APPLICATION ) &&

Token URL: { schema.get("tokenUrl") }

} + { ( flow === AUTH_FLOW_IMPLICIT || flow === AUTH_FLOW_ACCESS_CODE ) &&

Authorization URL: { schema.get("authorizationUrl") }

} + { ( flow === AUTH_FLOW_PASSWORD || flow === AUTH_FLOW_ACCESS_CODE || flow === AUTH_FLOW_APPLICATION ) &&

Token URL: { schema.get("tokenUrl") }

}

Flow: { schema.get("flow") }

{ - flow !== PASSWORD ? null + flow !== AUTH_FLOW_PASSWORD ? null : @@ -190,7 +190,7 @@ export default class Oauth2 extends React.Component { } { - ( flow === APPLICATION || flow === IMPLICIT || flow === ACCESS_CODE || flow === PASSWORD ) && + ( flow === AUTH_FLOW_APPLICATION || flow === AUTH_FLOW_IMPLICIT || flow === AUTH_FLOW_ACCESS_CODE || flow === AUTH_FLOW_PASSWORD ) && ( !isAuthorized || isAuthorized && this.state.clientId) && { @@ -198,7 +198,7 @@ export default class Oauth2 extends React.Component { : @@ -208,7 +208,7 @@ export default class Oauth2 extends React.Component { } { - ( (flow === APPLICATION || flow === ACCESS_CODE || flow === PASSWORD) && + ( (flow === AUTH_FLOW_APPLICATION || flow === AUTH_FLOW_ACCESS_CODE || flow === AUTH_FLOW_PASSWORD) && { isAuthorized ? ******