Skip to content

Commit

Permalink
refactor(auth): rename auth flow constants to be more descriptive (#7061
Browse files Browse the repository at this point in the history
)
  • Loading branch information
tim-lai authored Mar 10, 2021
1 parent 84358ae commit 21c2946
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/core/components/auth/oauth2.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -147,12 +147,12 @@ export default class Oauth2 extends React.Component {
{ isAuthorized && <h6>Authorized</h6> }

{ oidcUrl && <p>OpenID Connect URL: <code>{ oidcUrl }</code></p> }
{ ( flow === IMPLICIT || flow === ACCESS_CODE ) && <p>Authorization URL: <code>{ schema.get("authorizationUrl") }</code></p> }
{ ( flow === PASSWORD || flow === ACCESS_CODE || flow === APPLICATION ) && <p>Token URL:<code> { schema.get("tokenUrl") }</code></p> }
{ ( flow === AUTH_FLOW_IMPLICIT || flow === AUTH_FLOW_ACCESS_CODE ) && <p>Authorization URL: <code>{ schema.get("authorizationUrl") }</code></p> }
{ ( flow === AUTH_FLOW_PASSWORD || flow === AUTH_FLOW_ACCESS_CODE || flow === AUTH_FLOW_APPLICATION ) && <p>Token URL:<code> { schema.get("tokenUrl") }</code></p> }
<p className="flow">Flow: <code>{ schema.get("flow") }</code></p>

{
flow !== PASSWORD ? null
flow !== AUTH_FLOW_PASSWORD ? null
: <Row>
<Row>
<label htmlFor="oauth_username">username:</label>
Expand Down Expand Up @@ -190,15 +190,15 @@ export default class Oauth2 extends React.Component {
</Row>
}
{
( 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) && <Row>
<label htmlFor="client_id">client_id:</label>
{
isAuthorized ? <code> ****** </code>
: <Col tablet={10} desktop={10}>
<InitializedInput id="client_id"
type="text"
required={ flow === PASSWORD }
required={ flow === AUTH_FLOW_PASSWORD }
initialValue={ this.state.clientId }
data-name="clientId"
onChange={ this.onInputChange }/>
Expand All @@ -208,7 +208,7 @@ export default class Oauth2 extends React.Component {
}

{
( (flow === APPLICATION || flow === ACCESS_CODE || flow === PASSWORD) && <Row>
( (flow === AUTH_FLOW_APPLICATION || flow === AUTH_FLOW_ACCESS_CODE || flow === AUTH_FLOW_PASSWORD) && <Row>
<label htmlFor="client_secret">client_secret:</label>
{
isAuthorized ? <code> ****** </code>
Expand Down

0 comments on commit 21c2946

Please sign in to comment.