Skip to content

Commit dcd9b23

Browse files
community - fix token page expiration notice when auth provider is github (#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>
1 parent b498124 commit dcd9b23

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

CHANGES/2324.bug

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
community - fix token page expiration notice when auth provider is github

src/containers/token/token-standalone.tsx

+19-6
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ class TokenStandalone extends React.Component<RouteProps, IState> {
3939
const { token, alerts, loadingToken } = this.state;
4040
const unauthorised = !this.context.user || this.context.user.is_anonymous;
4141
const expiration = this.context.settings.GALAXY_TOKEN_EXPIRATION;
42-
const expirationDate = new Date(Date.now() + 1000 * 60 * expiration);
42+
const expirationDate = expiration
43+
? new Date(Date.now() + 1000 * 60 * expiration)
44+
: null;
45+
const isSSO =
46+
!this.context.user.auth_provider.includes('django') &&
47+
!this.context.user.auth_provider.includes('github');
4348

4449
return (
4550
<React.Fragment>
@@ -64,14 +69,22 @@ class TokenStandalone extends React.Component<RouteProps, IState> {
6469
<code>ansible-galaxy</code> client.
6570
</Trans>
6671
</p>
67-
{!this.context.user.auth_provider.includes('django') && (
72+
{isSSO && (
6873
<div>
6974
<h2>{t`Expiration`}</h2>
7075
<p>
71-
<Trans>
72-
You are an SSO user. Your token will expire{' '}
73-
<DateComponent date={expirationDate.toISOString()} />.
74-
</Trans>
76+
<Trans>You are an SSO user.</Trans>{' '}
77+
{expirationDate ? (
78+
<Trans>
79+
Your token will expire{' '}
80+
<DateComponent
81+
date={expirationDate.toISOString()}
82+
/>
83+
.
84+
</Trans>
85+
) : (
86+
<Trans>Your token will not expire.</Trans>
87+
)}
7588
</p>
7689
</div>
7790
)}

0 commit comments

Comments
 (0)