Skip to content

Commit

Permalink
community - fix token page expiration notice when auth provider is gi…
Browse files Browse the repository at this point in the history
…thub (#3879) (#3900)

allow for null token expiration,
but also don't treat github as SSO

Issue: AAH-2324
(cherry picked from commit 1976e22)

Co-authored-by: Martin Hradil <mhradil@redhat.com>
  • Loading branch information
patchback[bot] and himdel authored Jun 28, 2023
1 parent b498124 commit dcd9b23
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGES/2324.bug
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
community - fix token page expiration notice when auth provider is github
25 changes: 19 additions & 6 deletions src/containers/token/token-standalone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ class TokenStandalone extends React.Component<RouteProps, IState> {
const { token, alerts, loadingToken } = this.state;
const unauthorised = !this.context.user || this.context.user.is_anonymous;
const expiration = this.context.settings.GALAXY_TOKEN_EXPIRATION;
const expirationDate = new Date(Date.now() + 1000 * 60 * expiration);
const expirationDate = expiration
? new Date(Date.now() + 1000 * 60 * expiration)
: null;
const isSSO =
!this.context.user.auth_provider.includes('django') &&
!this.context.user.auth_provider.includes('github');

return (
<React.Fragment>
Expand All @@ -64,14 +69,22 @@ class TokenStandalone extends React.Component<RouteProps, IState> {
<code>ansible-galaxy</code> client.
</Trans>
</p>
{!this.context.user.auth_provider.includes('django') && (
{isSSO && (
<div>
<h2>{t`Expiration`}</h2>
<p>
<Trans>
You are an SSO user. Your token will expire{' '}
<DateComponent date={expirationDate.toISOString()} />.
</Trans>
<Trans>You are an SSO user.</Trans>{' '}
{expirationDate ? (
<Trans>
Your token will expire{' '}
<DateComponent
date={expirationDate.toISOString()}
/>
.
</Trans>
) : (
<Trans>Your token will not expire.</Trans>
)}
</p>
</div>
)}
Expand Down

0 comments on commit dcd9b23

Please sign in to comment.